while[exec("a=input().split();i=k"*2+"=100\nfor x in a:k-=x==ka[i-k]\ni+=k>49;k"*49)]:print(k)