#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
  ll N;
  cin >> N;
  string s[N];
  for (ll i = 0; i < N; i++) cin >> s[i];
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    string t[N];
    bool ok = 1;
    for (ll j = 0; j < N; j++) t[j] = (s[j] + s[j]).substr(i, N);
    for (ll j = 0; j < N; j++)
      for (ll k = 0; k < N; k++)
        if (t[k][j] != t[j][k]) ok = 0;
    if (ok) ans += N;
  }
  cout << ans << endl;
  return 0;
}
