#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef struct node{
struct node *lchild,*rchild;
int data;
}treeno,*treenode;
void cretree(treenode &root){
int x;
cin>>x;
if(x){
root=new treeno;
root->data=x;
cretree(root->lchild);
cretree(root->rchild);
}else{
root=NULL;
}
}
int getwidth(treenode root){
if(root==NULL) return 0;
treenode que[100];
treenode p;
int rear=1,front=1,last=1;
int width=0,max=1;
que[rear++]=root;
while(front<=last){
p=que[front++];
width++;
if(p->lchild!=NULL){
que[rear++]=p->lchild;
} if(p->rchild!=NULL){
que[rear++]=p->rchild;
}
if(front>last){
last=rear-1;
if(width>max) max=width;
width=0;
}
}
return max;
}
int main()
{
treenode root;
cretree(root);
int x=getwidth(root);
cout<<x;
return 0;
}//1 2 4 0 0 5 0 0 3 6 0 0 7 0 0