#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
  int N;
  cin >> N;

  string S[N];
  for ( int i = 0; i < N; i++ ) cin >> S[i];

  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    bool flag = true;
    for ( int j = 0; j < N; j++ ) {
      for ( int k = 0; k < N; k++ ) {
	if ( S[(j+i)%N][k] != S[(k+i)%N][j] ) {
	  flag = false;
	  j = N;
	  break;
	}
      }
    }

    if ( flag ) ans++;
  }

  cout << ans*N << endl;
  
  return 0;
}
