#include <bits/stdc++.h>
using namespace std;
int solve(int n, vector<string>& s) {
  vector<vector<char>> w(n * 2, vector<char>(n * 2));
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) {
      char ch = s[i][j];
      for (int a = 0; a < (2); ++a)
        for (int b = 0; b < (2); ++b) {
          w[i + n * a][j + n * b] = ch;
        }
    }
  int ans = 0;
  for (int of = 0; of < (n); ++of) {
    int neq = 0;
    for (int i = 0; i < (n)-1; ++i)
      for (int j = i + 1; j < (n); ++j) {
        if (w[of + i][j] != w[of + j][i]) ++neq;
      }
    if (neq == 0) ++ans;
  }
  return ans * n;
}
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < (n); ++i) cin >> s[i];
  cout << solve(n, s) << endl;
  return 0;
}
