soma=0
soma1=0
a, b= map(int,input().split())
while a!=-1 and b!=-1:
    if a==1 and b==1:
        soma+=1
        if soma1<=soma:
            soma1=soma
        a, b= map(int,input().split())
    elif a==1 and b==0:
        soma=0 
        a=int(input())
    if a==2 or a==1:
        a, b= map(int,input().split())
    elif a==0:
        a=int(input())
print(soma1)