#include<iostream>
#define maxn 10000
using namespace std;
int a[maxn];
int main()
{
int n;
cin>>n;
int height=1;
int index=2;
int temp=0;
while(true)
{
int temp=0;
for(int i=1;i<=index;i++)
{
cin>>a[i];
if(a[i]!=0)
temp++;
}
index=temp*2;
height+=1;
if(index==0)
break;
}
cout<<height;
}