1
1
#include<iostream>
using namespace std;
struct node
{
char date;
node *left, *right;
}*p;
void set(node *&p)
{
char ch;
cin >> ch;
if (ch == '#')
{
p = NULL;
}
else
{
p = new node;
p->date = ch;
set(p->left);
set(p->right);
}
}
int m;
void find(node *&p,int k)
{
if (p == NULL)
return;
if (m < k)
{
m = k;
}
find(p->left, 0);
find(p->right, k + 1);
}
int main()
{
set(p);
m = 0;
if (p->right != NULL)
{
cout << "ERROR";
}
else
{
find(p, 0);
cout << m + 1;
}
return 0;
}