N = int(input())						# 5

#A = list( list(input()) for _ in range(N) )

A=[]
for _ in range(N):
	a=list(input())
	b=list(a[:-1])
	a=a+b
	A.append(a)

#print(A)

for i in range(N-1):
	a=A[i]
	A.append(a)

#for i in range(N*2-1):
#	print(A[i])


count=0
bBreak=False
for i in range(N):
	for j in range(N):
		bBreak=False
		for x in range(N):
			for y in range(N):
				a=A[i+x][j+y]
				b=A[i+y][j+x]
				bBreak = (a!=b)
#				print(i, j, x, y, a, b, bBreak)
				if bBreak: break
			
			if bBreak: break
		else:
			count += 1
#		print("count=", count)

print(count)


