#include <bits/stdc++.h>
using namespace std;
template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT *delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> fld(n);
  for (auto &s : fld) {
    cin >> s;
  }
  int count = 0;
  for (int k = (int)(0); k < (int)(n); k++) {
    bool ok = true;
    for (int i = (int)(0); i < (int)(n); i++) {
      for (int j = (int)(0); j < (int)(n); j++) {
        if (fld[(i + k) % n][j] != fld[(j + k) % n][i]) {
          ok = false;
        }
      }
    }
    if (ok) {
      count++;
    }
  }
  cout << count * n << endl;
  return 0;
}
