def gcds(x):
  ret = n
  for y in x:
    ret = gcd(ret,y)
  return ret
import sys
input = sys.stdin.readline
from math import gcd
n = int(input())
a = [int(input(),16) for i in range(n)]
st = set()
for i in range(n):
  if i > 0:
    if a[i-1] != a[i]:
      st.add(i)
ans = gcds(st)
if ans == 1:
  print(1)
  exit()
ast = set(a)
for x in ast:
  x >>= 1
  for j in range(n-1):
    x >>= 1
    if (x&3)%3:
      st.add(j)
print(gcds(st))