#include <bits/stdc++.h>
using namespace std;
int n, c;
bool v;
string a[305];
int main() {
  int i, j, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i], a[i] += a[i];
  for (i = 0; i < n; i++) {
    for (j = v = 0; j < n; j++) {
      for (k = 0; k < n; k++)
        if (a[j][k + i] != a[k][j + i]) {
          v = 1;
          break;
        }
      if (v) break;
    }
    if (!v) c++;
  }
  cout << c * n << endl;
  return 0;
}
