n=io.read("*n")
s={}
for i=1,n do
	_=io.read(1)
	s[i]={}
	for j=1,n do
		s[i][j]=io.read(1)
	end
end
cnt=0
function func()
	for i=1,n do for j=1,n do
		if a[i][j]~=a[j][i] then return 0 end
	end end
	return n
end
for i=1,n do
	a={}
	for j=1,n do
		t=(j+i)%n+1
		a[j]={}
		for k=1,n do
			a[j][k]=s[t][k]
		end
	end
	cnt=cnt+func()
end
print(cnt)