#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
string s[311];
pair<int,int> sh[311][311][311];
pair<int,int> sv[311][311][311];

int main()
{
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	int h1, h2, hh1, hh2;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			h1=0;
			h2=0;
			hh1=0;
			hh2=0;
			for(int k = 0; k < n; k++){
				h1=h1*26+(s[(i+k)%n][j]-'a');
				h2=h2*26+(s[i][(j+k)%n]-'a');
				hh1=hh1*26+(s[(i+k)%n][j]-'a');
				hh2=hh2*26+(s[i][(j+k)%n]-'a');
				h1%=MOD1;
				h2%=MOD1;
				hh1%=MOD2;
				hh2%=MOD2;
				sv[i][j][k]=mp(h1,hh1);
				sh[i][j][k]=mp(h2,hh2);
			}
		}
	}
	int ans=0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			bool pos = 1;
			for(int k = 0; k < n; k++){
				if(sv[i][j][n-1-k]!=sh[i][j][n-1-k]){
					pos=0;
				}
			}
			ans+=pos;
		}
	}
	cout << ans;
	return 0;
}
