#include<bits/stdc++.h>
using namespace std;
char pre[1000];
int sum=0,i=0;
struct node
{
char data;
node *lchild;
node *rchild;
};
node *creat()
{
node *root;
char ch = pre[i++];
if(ch==',')
{
root=NULL;
}
else
{
root = new node();
root->data=ch;
root->lchild = creat();
root->rchild = creat();
}
return root;
}
void getleaf(node *root)
{
if(root)
{
if(root->lchild==NULL&&root->rchild==NULL)
{
sum++;
}
else
{
getleaf(root->lchild);
getleaf(root->rchild);
}
}
}
int main()
{
int t;
while(cin>>pre)
{
sum=0,i=0;
node *root = new node();
root = creat();
getleaf(root);
cout<<sum<<endl;
}
return 0;
}