n=int(input())
mat=list()
for i in range(n):
    s=bin(int(input(),16))[2:].zfill(n)
    mat.append(s)
    
x=1;

while x < n:
    f='false'
    for i in range(n):
        for j in range(n):
            if mat[i][j]!=mat[i//x][j//x]:
                f='true'
                break
        if f :
            break
    if f :
        break
    x=x*2
    
print(x)
    
            
