#include <bits/stdc++.h>
using namespace std;
int main() {
  char table[300][300] = {'\0'};
  char dust[10];
  int table_size = 0;
  int count = 0;
  bool flag = true;
  cin >> table_size;
  cout << table_size << "\n";
  for (int i = 0; i < table_size; i++) {
    for (int j = 0; j < table_size; j++) {
      cin >> table[i][j];
    }
  }
  for (int k = 0; k < table_size; k++) {
    for (int l = 0; l < table_size; l++) {
      for (int i = 0; (i < table_size) && (flag); i++) {
        for (int j = 0; (j < table_size) && (flag); j++) {
          if ((i != j) && (table[(i + k) % table_size][(j + l) % table_size] !=
                           table[(j + k) % table_size][(i + l) % table_size])) {
            flag = false;
          }
        }
      }
      if (flag == true)
        count++;
      else
        flag = true;
    }
  }
  printf("%d", count);
  return 0;
}
