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

x = 0

inp = sys.stdin.read().splitlines()

prev = ''
count = 0
for i in range(n):
    if inp[i]==prev:
        count += 1
    else:
        x = gcd(count,x)
        count = 1
        prev = inp[i]

        prev_c = ''
        counter = 0
        for c in prev:
            if c==prev_c:
                counter += 1
            else:
                x = gcd(x,counter)
                counter = 1
                prev_c = c
        x = gcd(x,counter)
    x = gcd(count,x)

print x
