#include <bits/stdc++.h>
int N;
char S[310][310];
int check(int A) {
  for (int i = 0; i < N; ++i) {
    int ii = (A + i) % N;
    for (int j = 0; j < N; ++j) {
      if (S[ii][j] != S[(A + j) % N][i]) {
        return 0;
      }
    }
  }
  return N;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%s", S[i]);
  }
  int count = 0;
  for (int A = 0; A < N; ++A) {
    count += check(A);
  }
  printf("%d\n", count);
  return 0;
}
