from fractions import gcd
d={
    "F":"0",
    "E":"1",
    "D":"2",
    "C":"3",
    "B":"4",
    "A":"5",
    "9":"6",
    "8":"7",
    "7":"0111",
    "6":"0110",
    "5":"0101",
    "4":"0100",
    "3":"0011",
    "2":"0010",
    "1":"0001",
    "0":"0000",
    }
n=input()
a=[]
c=1
s=raw_input()
x=""
for i in s:
    try:
        x+=d[i]
    except:
        x+=i
a.append(s)
m=n
f=False
for _ in range(n-1):
    s=raw_input()
    if f==False:
        r=""
        for i in s:
            try:
                r+=d[i]
            except:
                r+=i
        if x!=r:
            f=True
        if s==a[-1]:
            c+=1
        else:
            m=gcd(m,c)
            c=1
m=gcd(m,c)
if f and m==1:
    print 1
    exit(0)
b=""
for i in x:
    b+=d[i]
#print x,b
c=1
for i in range(1,n):
    if b[i]==b[i-1]:
        c+=1
    else:
        m=gcd(m,c)
        c=1
print m