#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<string>> line;
  line.resize(n);
  for (int i = 0; i < n; i++) {
    line[i].resize(n);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> line[i][j];
    }
  }
  int a = 0;
  int cnt = 0;
  for (int a = 0; a < n; a++) {
    int init = 1;
    for (int i = 0; i < n; i++) {
      for (int j = init; j < n; j++) {
        if (line[i][(j + a) % n].compare(line[(j + a) % n][i]) != 0) {
          goto L_NEXT;
        }
      }
    }
    cnt++;
  L_NEXT:
    init++;
  }
  return cnt;
}
