N = int(input())
S = [input() for _ in range(N)]
T = ["".join(s) for s in zip(*S)]
 
ans = 0
for _ in range(N):
    ans += (S == T)
    S = [s[-1] + s[:-1] for s in S]
    T = T[-1:] + T[:-1]
 
print(N * ans)