#include <bits/stdc++.h>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
long long N, ans;
vector<string> S(300);
int check(vector<string> S, int N, int A, int B) {
  for (int i = 0; i <= N - 2; i++) {
    for (int j = i + 1; j <= N - 1; j++) {
      if (S[(i + A) % N][(j + B) % N] != S[(j + A) % N][(i + B) % N]) {
        return 0;
      }
    }
  }
  return 1;
}
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  for (int A = 0; A < N; A++) {
    for (int B = 0; B < N; B++) {
      int x = check(S, N, A, B);
      ans += x;
    }
  }
  cout << ans << endl;
  return 0;
}
