#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<string> g(n), g2(n);
  for (int i = 0, _i = (n); i < _i; ++i) cin >> g[i];
  for (int i = 0, _i = (n); i < _i; ++i) {
    for (int j = 0, _i = (n); j < _i; ++j) g2[(j + i) % n] = g[j];
    bool f = true;
    for (int p = 0, _i = (n); p < _i; ++p)
      for (int q = 0, _i = (p); q < _i; ++q)
        if (g2[p][q] != g2[q][p]) {
          f = false;
          break;
        }
    if (f) ans += n;
  }
  cout << ans << endl;
  return 0;
}
