import sys
range = xrange
input = raw_input

def gcd(a,b):
    if b==0:return a
    while a>0:
        a,b = b%a,a
    return b

n = int(input())

hex2bin = ['']*256
hex2bin[ord('0')] = '0000'
hex2bin[ord('1')] = '0001'
hex2bin[ord('2')] = '0010'
hex2bin[ord('3')] = '0011'
hex2bin[ord('4')] = '0100'
hex2bin[ord('5')] = '0101'
hex2bin[ord('6')] = '0110'
hex2bin[ord('7')] = '0111'
hex2bin[ord('8')] = '1000'
hex2bin[ord('9')] = '1001'
hex2bin[ord('A')] = '1010'
hex2bin[ord('B')] = '1011'
hex2bin[ord('C')] = '1100'
hex2bin[ord('D')] = '1101'
hex2bin[ord('E')] = '1110'
hex2bin[ord('F')] = '1111'


buckets = [0]*(n+1)

inp = [line for line in sys.stdin.read().splitlines()]

i = 0
while i<n:
    l = i+1
    while l<n and inp[i] == inp[l]:l+=1 
    buckets[l-i] += 1
    
    if buckets[1]!=0 or (buckets[2]!=0 and buckets[3]!=0):
        print 1
        sys.exit()

    bits = ''.join(hex2bin[ord(c)] for c in line)
    j = 0
    while j<n:
        cur_b = bits[j]
        k = j+1
        while k<n and bits[k]==cur_b:k+=1
        buckets[k-j]+=1
        j = k
    i = l


x = n
for i in range(1,n+1):
    if buckets[i]:
        x = gcd(i,x)
print x