#include<bits/stdc++.h>
using namespace std;
typedef char ElementType;
typedef struct TNode *Position;
typedef Position BinTree;
struct TNode{
ElementType Data;
BinTree Left;
BinTree Right;
};
void CreatBinTree(BinTree &BT);
int GetHeight( BinTree BT );
int main()
{
BinTree BT;
CreatBinTree(BT);
char a[]="ABDFECGHI//ABD##FE###CG#H##I##";
printf("%d\n", GetHeight(BT));
return 0;
}
void CreatBinTree(BinTree &BT)
{
char c;
cin>>c;
if('#'==c)
BT=NULL;
else
{
BT=new TNode;
BT->Data=c;
CreatBinTree(BT->Left);
CreatBinTree(BT->Right);
}
}
int GetHeight( BinTree BT )
{
if(BT==NULL)
{
return 0;
}
int a=GetHeight(BT->Left);
int b=GetHeight(BT->Right);
return (a>b?a:b)+1;
}