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)
ok = []
for i in range(1, n + 1):
    if (n % i == 0):
        c = 1
        for j in range(n//i):
            if (not all(x == C[j * i] for x in C[j * i : (j + 1) * i])):
                c = 0
                break
        if c == 1:
            ok.append(i)
for i in range(n - 1):
    x = input()
    A.append(x)
ok.reverse()
for i in ok:
    if (n % i == 0):
        c = 1
        for j in range(n//i):
            if (not all(x == C[j * i] for x in C[j * i : (j + 1) * i])):
                c = 0
                break
        if c == 1:
            ans = i
            break
print(i)

