#include<bits/stdc++.h>
using namespace std;
int n;
char a[310][310],b[310][310];
long long as;
bool chk(){
	register int i,j;
	for(i = 2;i <= n;++i){
		for(j = 1;j < i;++j){
			if(b[i][j] != b[j][i]) return 0;
		}
	}
	return 1;
}
int main(){
	register int i,j,k;
	cin>>n;
	for(i = 1;i <= n;++i) scanf("%s",a[i] + 1);
	for(i = 0;i < n;++i){
		for(j = 1;j <= n;++j){
			for(k = 1;k <= n;++k) b[j][(k + i - 1) % n + 1] = a[j][k];
		}
		if(chk()) as += n;
	}
	cout<<as;
	return 0;
}