#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void getprime(int);
string decToBinary(long long);
bool spsort(const pair<long long, long long> &a,
            const pair<long long, long long> &b) {
  if (a.first != b.first)
    return (a.first > b.first);
  else
    return (a.second < b.second);
}
bool sortsec(const pair<long long, long long> &a,
             const pair<long long, long long> &b) {
  return (a.second < b.second);
}
int numofBits(long long x) {
  if (x == 0) {
    return 0;
  }
  return floor(log2(x)) + 1;
}
template <typename T>
long long lcm(T a, T b) {
  return (long long)(a / __gcd(a, b)) * b;
}
unsigned long long leastSetBitpos(long long n) { return log2(n & -n) + 1; }
template <typename T>
T mostSignificantBit(T n) {
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  ++n;
  return (n >> 1);
}
template <typename T>
bool isprime(T n) {
  if (n <= 1) return false;
  for (long long i = 2; (i * i) <= n; i++)
    if (n % i == 0) return false;
  return true;
}
bool ispalin(string s) {
  long long j = s.size() - 1, i = 0;
  while (i < j) {
    if (s[i] != s[j]) return false;
    ++i;
    --j;
  }
  return true;
}
template <typename T>
T getmod(T x, T mod) {
  T z = x % mod;
  if (z >= 0)
    return z;
  else
    return (z + 1000000007);
}
const long double PI = acos(-1);
const int max_bits = 32;
const int primel = 1000050;
bool prime[primel];
void AJM() {
  int n;
  cin >> n;
  map<pair<string, string>, int> m;
  for (int i = 0; i < n; i++) {
    if (i != 0) {
      string s;
      cin >> s;
    }
    string s, s1;
    cin >> s >> s1;
    bool ok = true;
    for (int i = 0; i < 4; i++) {
      swap(s[0], s1[0]);
      swap(s1[0], s1[1]);
      swap(s1[1], s[1]);
      if (i != 3 && m[{s, s1}]) {
        ok = false;
        m[{s, s1}]++;
        break;
      }
    }
    if (ok) m[{s, s1}]++;
  }
  int ans = 0;
  for (auto x : m) {
    if (x.second) ans++;
  }
  cout << ans << "\n";
  return;
}
bool GOOGLE = 0;
bool txtinp = 1;
bool TC = 0;
int main() {
  if (txtinp) {
  }
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(nullptr);
  long long t = 1;
  if (TC) cin >> t;
  long long tc = 1;
  while (t--) {
    if (GOOGLE) cout << "Case #" << tc << ": ";
    ++tc;
    AJM();
  }
  return 0;
}
void getprime(int primel) {
  int a = primel;
  prime[0] = prime[1] = false;
  for (int i = 2; i < a + 1; i++) prime[i] = true;
  for (int p = 2; (p * p) <= a; p++) {
    if (prime[p] == true) {
      for (int i = (p * p); i <= a; i += p) prime[i] = false;
    }
  }
}
string decToBinary(long long n) {
  bitset<max_bits> b(n);
  return b.to_string();
}
