def factors(a):
    ff=set()
    i=1
    while i*i<=a:
        if a%i==0:ff.add(i);ff.add(n//i)
        i+=1
    return list(ff)
n=int(input())
a=[input() for i in range(n)]
sol={'0':'0000','1':'0001','2':'0010','3':'0011','4':'0100','5':'0101','6':'0110','7':'0111','8':'1000','9':'1001','A':'1010','B':'1011','C':'1100','D':'1101','E':'1110','F':'1111'}
aa=[]
for i in a:
    x=''
    for j in i:
        x+=sol[j]
    aa.append(x)
f=factors(n)
f.sort()
from math import ceil as cl
#print(f,n,aa)
for i in f:
    ch=0
    for j in range(n):
        if ch==1:break
        for k in range(n):
            if aa[j][k]!=aa[j%i][k%i]:
                ch=1
                break
    #print(ch,i,j,k)
    if ch==0:print(n//i);exit()
print(1)
