#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef struct node{
char data;
struct node *lchild,*rchild;
}treeno,*treenode;
void cre(treenode &root){
char x;
cin>>x;
if(x=='@') root=NULL;
else{
root=new treeno;
root->data=x;
cre(root->lchild);
cre(root->rchild);
}
}
int f(treenode root){
if(!root) return 0;
if(!root->lchild&&!root->rchild) return 1;
return f(root->lchild)+f(root->rchild);
}
int main()
{
treenode root;
cre(root);
int x=f(root);
cout<<x<<endl;
//ABD@@E@@CF@@G@@
return 0;
}