ans=0
def check22(w):
    global ans
    for i in range(0,n,w):
        for j in range(0,n,w):
            for p in range(w):
                for q in range(w):
                    if mat[p+i][q+j]!=mat[i][j]:
                        return
    ans=max(ans,w)


n=int(input())
mat=[]
ss=n
for i in range(n):
    s=int(input(),16)
    k=list(bin(s))
    x=[0 for _ in range(n)]

    for r in range(2,len(k)):

            x[r-2]=int(k[r])
    mat.append(x)
for w in range(2,n//2+1):
    check22(w)
check22(n)
print(ans)