from fractions import gcd
d={
    "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",
}
def fun(x,n):
    p=n
    c=0
    r=d[x[0]][0]
    for i in x:
        for j in d[i]:
            #print j,r
            if j==r:
                c+=1
            else:
                p=gcd(p,c)
                c=1
            r=j[::]
    p=gcd(p,c)
    return p

n=input()
m=n
r=raw_input()
m=gcd(m,fun(r,n))
#print m
f=False
c=1
for _ in range(n-1):
    s=raw_input()
    if f==False:
        m=gcd(m,fun(s,n))
        if r==s:
            c+=1
        else:
            m=gcd(m,c)
            c=1
        r=s[::]
        if m==1:
            f=True
print m