import math
import sys
import bisect
#input=sys.stdin.readline
#t=int(input())
t=1
def d2b(x):
    s1=''
    for i in range(3,-1,-1):
        k=x>>i
        if k&1:
            s1+='1'
        else:
            s1+='0'
    return s1        
            
def divisor(x):
    i=2
    l1=[]
    while i*i<=x:
        if x%i==0:
            if x//i==i:
                l1.append(i)
            else:
                l1.append(x//i)
                l1.append(i)
        i+=1
    return l1            
for _ in range(t):
    #mod=10**9+7
    n=int(input())
    #n,k=map(int,input().split())
    #l=list(map(int,input().split()))
    #s=input()
    l=[]
    
    for i in range(n):
        s=input()
        s2=''
        for j in range(n//4):
            if s[j].isdigit():
                s2+=d2b(int(s[j]))
            else:
                s2+=d2b(ord(s[j])-55)
        l.append(s2)
    l2=divisor(n)   
    l2.sort(reverse=True)
    val=[]
    flag=True
    ans=1
    #print(l2)
    for i1 in range(len(l2)):
        flag=True
       
        for i in range(l2[i1]):
            for j in range(l2[i1]):
                #print()
                for k1 in range(n//l2[i1]):
                    for k2 in range(n//l2[i1]):
                        #print(i+k1*(l2[i1])+1,j+k2*(l2[i1])+1)
                        if l[i][j]!=l[i+k1*(l2[i1])][j+k2*(l2[i1])]:
                            flag=False
                    if flag==False:
                        break
                if flag==False:
                    break
            if flag==False:
                break
        if flag==True:
            ans=l2[i]
            break
    print(ans)