import math
import string

n = int(input())
g = n

for j in range(n):
    L = [int(i,16) for i in input()]
    s = []
    for i in L:
        s.extend([i for i in bin(i)[2:].zfill(4)])
    t = []
    r = 1
    temp = 0
    for i in range(n-1):
        if s[i+1] == s[i]:
            temp += 1
        else:
            t.append(temp)
            temp = 1
    t.append(temp)
    for i in t:
        g = math.gcd(g,i)
    if g == 1:
        break

print(g)