#include <bits/stdc++.h>
using namespace std;
char s[600][600];
int main() {
  int n;
  cin >> n;
  for (int(i) = 0; (i) < (n); i++)
    for (int(j) = 0; (j) < (n); j++) {
      cin >> s[i][j];
      s[i + n][j + n] = s[i + n][j] = s[i][j + n] = s[i][j];
    }
  int res = 0;
  for (int(i) = 0; (i) < (n); i++)
    for (int(j) = 0; (j) < (n); j++) {
      bool isGood = true;
      for (int(k) = 0; (k) < (n); k++)
        for (int(l) = 0; (l) < (n); l++) {
          if (!isGood) break;
          if (s[i + k][j + l] != s[i + l][j + k]) isGood = false;
        }
      if (isGood) res++;
    }
  cout << res << endl;
}
