n = int(input())
hex = {"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"} 
a = ['' for i in range(n)]
l, ans = 0, 1
for i in range(n):
    s = input()
    for c in s:
        a[l] += hex[c]
    l += 1
b = []
for i in range(2, n + 1):
    if n % i == 0:
        b.append(i)
for i in b:
    for j in range(n // i):
        mn = 0
        mx = 0
        for k in range(n // i):
            if '1' in a[j * i + k][j * i:(j+1) * i]:
                mn += 1
            if '0' in a[j * i + k][j * i:(j+1) * i]:
                mx += 1
        if (mx > 0) & (mn > 0):
            print(ans)
            exit(0)
    ans = i
print(ans)