#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<vector<char>> S;
  S = vector<vector<char>>(N, vector<char>(N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> S[i][j];
    }
  }
  int count = 0;
  for (int A = 0; A < N; A++) {
    for (int B = 0; B < N; B++) {
      int flag = 0;
      for (int i = -A; i < N - A && flag == 0; i++) {
        for (int j = i; j < N - B; j++) {
          if (S[i >= 0 ? i : i + N][j >= 0 ? j : j + N] !=
              S[j >= 0 ? j : j + N][i >= 0 ? i : i + N]) {
            flag = -1;
            break;
          }
        }
      }
      if (flag == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
