#include <bits/stdc++.h>
using namespace std;
const int infnity = -1;
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long aa = power(a, b / 2);
  aa *= aa;
  if (b % 2 == 1) {
    aa *= a;
  }
  return aa;
}
bool aresame(string a, string b) {
  if (a == b) return true;
  for (int i = 1; i < 4; i++) {
    string bb;
    bb.push_back(b[3]);
    for (int i = 0; i < 3; i++) bb.push_back(b[i]);
    b = bb;
    if (a == b) return true;
  }
  return false;
}
int main() {
  vector<string> vv;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string a, b;
    if (i > 0) cin >> a;
    cin >> a >> b;
    reverse(b.begin(), b.end());
    bool is = false;
    a = a + b;
    for (int j = 0; j < vv.size(); j++) {
      if (aresame(vv[j], a)) {
        is = 1;
        break;
      }
    }
    if (!is) vv.push_back(a);
  }
  cout << vv.size() << endl;
  return 0;
}
