#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 300 + 10;
int N;
char S[MAXN][MAXN];
int ans;

int main() {
	register int i, j, k;
	scanf( "%d", &N );
	for( i = 0; i < N; ++i )
		scanf( "%s", S[i] );
	for( i = 0; i < N; ++i ) {
		bool flag = 1;
		for( j = 0; j < N; ++j )
			for( k = j + 1; k < N; ++k )
				if( S[( i + j ) % N][k] != S[( i + k ) % N][j] )
					flag = 0;
		ans += flag;
	}
	printf( "%d\n", ans * N );
	return 0;
}