#include <bits/stdc++.h>
using namespace std;
bool yes(string a, string b) {
  if (a == b) return 1;
  swap(a[0], a[1]), swap(a[0], a[3]), swap(a[0], a[2]);
  if (a == b) return 1;
  swap(a[0], a[1]), swap(a[0], a[3]), swap(a[0], a[2]);
  if (a == b) return 1;
  swap(a[0], a[1]), swap(a[0], a[3]), swap(a[0], a[2]);
  if (a == b) return 1;
  return 0;
}
int main() {
  int n, sz, k = 0;
  string a, b, c;
  pair<string, string> sp;
  vector<string> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    a += b;
    bool bb = 0;
    for (int j = 0; j < v.size(); j++)
      if (yes(v[j], a)) {
        bb = 1;
        break;
      }
    if (!bb) v.push_back(a);
  }
  cout << v.size();
  return 0;
}
