#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> dominos;
  int fichas;
  cin >> fichas;
  string str1, str2, aux;
  for (int i = int(0); i < int(fichas); i++) {
    cin >> str1 >> str2 >> aux;
    reverse(str2.begin(), str2.end());
    aux.clear();
    aux = str1 + str2 + str1 + str2;
    str1 += str2;
    bool estado = 0;
    for (int j = int(0); j < int(dominos.size()); j++) {
      int found = dominos[j].find(str1);
      if (found != -1) {
        estado = 1;
      }
    }
    if (estado == 0) {
      dominos.push_back(aux);
    }
  }
  cout << dominos.size();
}
