n=int(input()) a=[list(map(int, input().split())) for i in range(n)] M=200001 X=[0]*M Y=[0]*M for x, y in a: X[x]+=1 Y[y]+=1 c=0 for i in range(M): c+=abs(X[i]-Y[i]) c//=2 if c==0: print(2) elif c==1: print(1) else: print(0)