#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (int i = 0; i < (v.size()); i++) {
    os << v[i] << (i == v.size() - 1 ? "" : " ");
  }
  return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v) {
    is >> x;
  }
  return is;
}
int main() {
  int n;
  cin >> n;
  vector<string> s(n + n);
  for (int i = 0; i < (n); i++) {
    cin >> s[i];
    s[i] += s[i];
    s[i + n] = s[i];
  }
  vector<vector<int>> no(n + n + n, vector<int>(n + n + n, false));
  for (int i = 0; i < (n + n); i++) {
    for (int j = (0); j < (n + n); j++) {
      int ni = i + 1, nj = j - 1;
      int p = 0;
      while (i - p >= 0 and ni + p < n + n - 1 and j + p < n + n - 1 and
             nj - p >= 0) {
        if (s[i - p][j + p] != s[ni + p][nj - p]) {
          int d = max(0, max(-(i + p - 2), -(nj + p - 2)));
          no.at(i + p - 2 + d).at(nj + p - 2 + d)++;
          no.at(i + p + 1).at(nj + p + 1)--;
          break;
        }
        p++;
      }
    }
  }
  for (int i = 0; i < (n + n); i++) {
    for (int j = (0); j < (n + n); j++) {
      int ni = i + 2, nj = j - 2;
      int p = 0;
      while (i - p >= 0 and ni + p < n + n - 1 and j + p < n + n - 1 and
             nj - p >= 0) {
        if (s[i - p][j + p] != s[ni + p][nj - p]) {
          int d = max(0, max(-(i + p - 2), -(nj + p - 2)));
          no.at(i + p - 2 + d).at(nj + p - 2 + d)++;
          no.at(i + p + 1).at(nj + p + 1)--;
          break;
        }
        p++;
      }
    }
  }
  for (int i = 0; i < (n + n + n); i++) {
    for (int j = 0; j < (n + n + n); j++) {
      if (i - 1 < 0 or j - 1 < 0) continue;
      no[i][j] += no[i - 1][j - 1];
    }
  }
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (n); j++) {
      ans += no[i][j] ? 0 : 1;
    }
  }
  cout << ans << endl;
}
