#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
pair<long long, long long> Dir[8] = {{0, 1}, {-1, 0}, {1, 0},  {0, -1},
                                     {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
struct Edge {
  int from, to;
  long long w;
};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long m, long long n) { return m * n / gcd(m, n); }
long long gettugibaisu(long long from, long long k) {
  long long ret = ((from + k - 1) / k) * k;
  return ret;
}
long long getmaebaisu(long long to, long long k) {
  long long ret = (to / k) * k;
  return ret;
}
class Loli {
  string str;
  vector<int> hash, pw;
  int mod = 1000000007, base = 524287;

 public:
  Loli(string str)
      : str(str), hash(str.length() + 1), pw(str.length() + 1, 1) {}
  void calc() {
    for (int i = (1); (str.length() + 1) > i; i++) {
      pw[i] = ((long long)pw[i - 1] * base) % mod;
      hash[i] = ((long long)hash[i - 1] * base + (int)str[i - 1]) % mod;
    }
  }
  int gethash(int l, int r) {
    return (hash[r] - (long long)hash[l] * pw[r - l] % mod + mod) % mod;
  }
};
signed main(void) {
  int n;
  cin >> n;
  int l = 2 * n - 1;
  vector<string> s(l);
  vector<Loli> lsh, lsv;
  for (int i = (0); (n) > i; i++) {
    cin >> s[i];
    s[i] += s[i];
    s[i].erase(--s[i].end());
    if (i != n - 1) s[i + n] = s[i];
  }
  for (int i = (0); (l) > i; i++) {
    lsh.push_back(Loli(s[i]));
    lsh[i].calc();
  }
  for (int i = (0); (l) > i; i++) {
    string buf;
    for (int j = (0); (l) > j; j++) {
      buf += s[j][i];
    }
    lsv.push_back(Loli(buf));
    lsv[i].calc();
  }
  int cou = 0;
  for (int x = (0); (l - n + 1) > x; x++) {
    for (int y = (0); (l - n + 1) > y; y++) {
      bool f = true;
      for (int i = (0); (n) > i; i++) {
        if (lsh[y + i].gethash(x + 1 + i, x + n) !=
            lsv[x + i].gethash(y + 1 + i, y + n)) {
          f = false;
          break;
        }
      }
      if (f) cou++;
    }
  }
  cout << cou << endl;
  return 0;
}
