import math
import re



def is_compressable(arr, x):
    i = 0
    for i in range(0, len(arr), x):
        for j in range(0, len(arr), x):
            cells = [arr[i][j//4], arr[i+x-1][j//4], arr[i+x-1][(j+x-1)//4], arr[i][(j+x-1)//4]]
            for cell in cells:
                if cell != cells[0]:
                    return False
    return True


if __name__ == '__main__':
    n = int(input())
    arr = [None] * n
    for i in range(n):
        arr[i] = input()
    for s in arr:
        if not re.match(r'^[C03F]+$', s):
            print(1)
            exit()
    for i in range(0, len(arr), 2):
        if arr[i] != arr[i+1]:
            print(1)
            exit()
    x = 4
    while x <= n:
        if is_compressable(arr, x):
            x *= 2
        else:
            break
    print(x // 2)
