#include <bits/stdc++.h>
using namespace std;
int s[933][933];
int n;
long long pw[333];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
    ;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    string fuck;
    cin >> fuck;
    for (int j = 0; j < n; j++) {
      s[i][j] = s[i][j + n] = s[i][j + n + n] = s[i + n][j] = s[i + n][j + n] =
          s[i + n][j + n + n] = s[i + n + n][j] = s[i + n + n][j + n] =
              s[i + n + n][j + n + n] = fuck[j] - 'a';
    }
  }
  pw[0] = 1;
  for (int i = 1; i < 333; i++) {
    pw[i] = pw[i - 1] * 29 % ((int)1e9 + 7);
  }
  int ans = 0;
  for (int A = 0; A < n; A++) {
    vector<long long> row, col;
    for (int i = 0; i < n - 1; i++) {
      long long hs = 0;
      int x = A + i;
      int y = i + 1;
      for (int j = 0; j < n - i - 1; j++) {
        hs = (hs + s[x][y + j] * pw[j]) % ((int)1e9 + 7);
      }
      row.push_back(hs);
    }
    for (int i = 0; i < n - 1; i++) {
      long long hs = 0;
      int x = A + i + 1;
      int y = i;
      for (int j = 0; j < n - i - 1; j++) {
        hs = (hs + s[x + j][y] * pw[j]) % ((int)1e9 + 7);
      }
      col.push_back(hs);
    }
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < n - 1; i++) {
        int x = A + i;
        int y = i + 1 + j;
        row[i] -= s[x][y];
        row[i] += s[x][y + n - i - 2] * pw[n - i - 2];
        row[i] += ((int)1e9 + 7);
        row[i] %= ((int)1e9 + 7);
      }
      for (int i = 1; i < n - 1; i++) {
        int x = A + i + 1;
        int y = i + j;
        col[i] *= 29;
        col[i] += s[x][y - 1];
        col[i] %= ((int)1e9 + 7);
        col[i - 1] = col[i];
      }
      col[n - 2] = s[A + n][j + n - 1];
      if (row == col) ans++;
    }
  }
  cout << ans << endl;
  ;
  return 0;
}
