n = int(input())
s = [input() for i in range(n)]

cnt = 0

for i in range(n):
    i_ = (n+i)%n
    for k in range(n):
        for l in range(n):
            if s[(i_+k)%n][l] != s[(i_+l)%n][k]:
                break
        else:
            continue
        break
    else:
        cnt += 1

print(cnt*n)