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())

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 = bin(int(inp[i],16))
    m = len(bits)
    if bits!='0b0':
        j = 2
        while j<m:
            cur_b = bits[j]
            k = j+1
            while k<m 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]:
        while i:
            i,x = x%i,i
print x