#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_set<string> s;
  for (int i = 0; i < n; i++) {
    string l, m;
    char A, B;
    cin >> l >> m >> A >> B;
    reverse(m.begin(), m.end());
    string p, a, b, c, d;
    p += l;
    p += m;
    a = p;
    rotate(p.begin(), p.begin() + 3, p.end());
    b = p;
    rotate(p.begin(), p.begin() + 3, p.end());
    c = p;
    rotate(p.begin(), p.begin() + 3, p.end());
    d = p;
    if (!s.count(a) and !s.count(b) and !s.count(c) and !s.count(d))
      s.insert(a);
  }
  (!s.empty()) ? cout << s.size() : cout << 0;
  return 0;
}
