n = int(input())
a = []
c = []
x = input()
a.append(x)
for j in x:
    d = list(map(int,list(bin(int(j, 16))[2:])))
    for _ in range(len(d), 4):
        c.append(0)
    c.extend(d)
b = []
for i in range(1, n + 1):
    if (n % i == 0):
        cat = 1
        for j in range(n // i):
            V = c[j * i : (j + 1) * i]
            v = c[j * i]
            if (not all(x == v for x in V)):
                cat = 0
                break
        if cat == 1:
            b.append(i)
for i in range(n - 1): 
    x = input()
    a.append(x)
b.reverse()
for i in b:
    if (n % i == 0):
        cat = 1
        for j in range(n // i):
            if (not all(x == a[j * i] for x in a[j * i : (j + 1) * i])):
                cat = 0
                break
        if cat == 1:
            ans = i
            break
print(i)