N = int(input())
chars1 = []
for i in range(N):
    chars1.append(list(input()))
chars2 = chars1
suman = 0

for A in range(N):
    for B in range(N):
        for i in range(N):
            for j in range(A,N):
                cha1 = chars1
                cha2 = chars2
                a = A
                b = B
                if (i+A)>N:
                    a-=(N-1)
                if (j+B)>N:
                    b-=(N-1)
                cha2[i][j] = cha1[i+a][j+b]
                ans = 1
        for k in range(N):
            for l in range(k,N):
                if not cha2[k][l]==cha2[l][k]:
                    ans = 0
        suman += ans

print(suman)
