#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;
return max(f(root->lchild),f(root->rchild))+1;
}
int main()
{
treenode root;
cre(root);
int x=f(root);
cout<<x<<endl;
//ABD@@E@@CF@@G@@
return 0;
}