n = int(input())
a = []
for i in range(n):
    a.append(input())

for i in range(n):
    a.append(a[i])


x = 0

for i in range(n):
    for j in range(n):
        for k in range(j+1):
            if a[i+j][k]==a[i+k][j]:
                continue
            else:
                break
        else:
            continue
        break
    else:
        x += 1

print(n*x)

 