
dict_16_2 = {"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"}


n = int(input())
mass1 = ''
mass2 = ''
for y in range(n):
    s = input()
    mass1 += s
    for i in range(0, len(s)):
        z = dict_16_2[s[i]]
        mass2 += z[:2]
        mass2 += z[2:]
bah = 1
for x in range(2, n+1):
    if n % x == 0 and (mass1.count(mass1[:x]) == n//x or mass2.count(mass1[:x]) == n//x):
        bah = x
print(bah)