#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>
#include<algorithm>
typedef struct Tree_node
{
char data;
struct Tree_node* left_child;
struct Tree_node* right_child;
}TN;
TN* creat()
{
TN* root = (TN*)malloc(sizeof(TN));
char ch;
scanf("%c", &ch);
if (ch == '#')
{
return NULL;
}
else
{
root->data = ch;
root->left_child = creat();
root->right_child = creat();
}
return root;
}
int depth(TN* root)
{
if (root == NULL)return 0;
int n = depth(root->left_child);
int m = depth(root->right_child);
return m > n ? m + 1 : n + 1;
}
int k_node(TN* root,int k)
{
if (root == NULL)return 0;
if (k == 1)return 1;
return k_node(root->left_child, k - 1) + k_node(root->right_child, k - 1);
}
int main()
{
TN* root = creat();
int high = depth(root);
int ans = -1;
for (int i = 1; i <= high; i++)
{
ans = std::max(ans, k_node(root, i));
}
printf("%d", ans);
return 0;
}