import sys
n = int(sys.stdin.readline())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = bin((1 << n) | int(sys.stdin.readline(), 16))[3:]

# check input time
if n < 100:
    from math import gcd
    ans = 0
    for i in range(n):
        j = 0
        while j < n:
            k = j + 1
            while k < n and a[i][j] == a[i][k]:
                k += 1
            ans = gcd(ans, k - j)
            j = k
        j = 0
        while j < n:
            k = j + 1
            while k < n and a[j][i] == a[k][i]:
                k += 1
            ans = gcd(ans, k - j)
            j = k

    print(ans)
