n = int(input())
bd1 = [[0 for i in range(n)] for j in range(n)]
bd2 = [[0 for i in range(n)] for j in range(n)]
for i  in range(n):
    x = input()
    bd1[i] = list(x)
cnt = 0
for a in range(n):
    for b in range(n):
        for i in range(n):
            for j in range(n):
                if i+a >= n:
                    i -= n
                if j+b >= n:
                    j -= n
                bd2[i][j] = bd1[i+a][j+b]
        judge = 0
        for i in range(n):
            for j in range(n):
                if bd2[i][j] != bd2[j][i]:
                    judge += 1
        if judge == 0:
            cnt += 1
print(cnt)
