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