#include <bits/stdc++.h>
inline int getint() {
  int x = 0, p = 1;
  char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int maxn = 300 + 10;
int n;
char s[maxn][maxn], s2[maxn][maxn];
bool check(int x, int y) {
  for (int(t) = 0; (t) < (800); (t)++) {
    int i = rand() % n, j = rand() % n;
    int xx = i - x;
    if (xx < 0) xx += n;
    int yy = j - y;
    if (yy < 0) yy += n;
    int xxx = j - x;
    if (xxx < 0) xxx += n;
    int yyy = i - y;
    if (yyy < 0) yyy += n;
    if (s[xx][yy] != s[xxx][yyy]) return false;
  }
  return true;
}
int main() {
  srand(time(0));
  n = getint();
  for (int(i) = 0; (i) < (n); (i)++) scanf("%s", s[i]);
  int ans = 1000000000, ans2 = -1;
  int res = 0;
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (n); (j)++)
      if (check(i, j)) res++;
  printf("%d\n", res);
  return 0;
}
