import atexit, io, sys 
  
# A stream implementation using an in-memory bytes  
# buffer. It inherits BufferedIOBase. 
buffer = io.BytesIO() 
sys.stdout = buffer
  
# print via here 
@atexit.register 
def write(): 
    sys.__stdout__.write(buffer.getvalue())

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

n=int(raw_input())
arr=[]
mindiff=10**9
ans=-1
flag=0
for i in range(n):
	s=raw_input()
	s1=''
	j=0
	while(j<len(s)):
		if(65<=ord(s[j])<=70):
			num=10+(ord(s[j])-65)
			s1+=bin(num)[2:]
		else:
			num=bin(int(s[j]))[2:]
			num=(4-len(num))*'0'+num
			s1+=num
		j+=1
	initial=s1[0]
	j=1
	count=1
	while(j<len(s1)):
		if(s1[j]==initial):
			count+=1	
		else:
			if(ans==-1):
				ans=count
			else:
				ans=gcd(ans,count)
			count=1
			initial=s1[j]
		j+=1
	if(ans==-1):
		ans=count
	else:
		ans=gcd(ans,count)
	arr.append(s1)
#print(*arr)
if(ans==1):
	print(1)
	exit(0)
for i in range(n):
	initial=arr[0][i]
	count=1
	for j in range(1,n):
		if(arr[j][i]==initial):
			count+=1	
		else:
			ans=gcd(ans,count)
			count=1
			initial=arr[j][i]
			if(ans==1):
				print(1)
				exit(0)
	ans=gcd(ans,count)
	if(ans==1):
		print(1)
		exit(0)
print(ans)

