#include <bits/stdc++.h>
using namespace std;
const int maxn = 305;
string s[maxn];
string t[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    t[i] = s[i];
  }
  int res = 0;
  for (int a = 0; a < n; ++a) {
    for (int b = 0; b < n; ++b) {
      bool ok = 1;
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
          t[i][j] = s[(i + a) % n][(j + b) % n];
        }
      }
      for (int i = 0; i < n && ok; ++i) {
        for (int j = 0; j < n && ok; ++j) {
          if (t[i][j] != t[j][i]) {
            ok = 0;
          }
        }
      }
      res += ok;
    }
  }
  cout << res << endl;
  return 0;
}
