#include <bits/stdc++.h>
using namespace std;
int num[6667];
int main() {
  int k, i, j, a, b, n, len, m, counter = 0;
  char c1, c2;
  cin >> n;
  for (i = 0; i < n; i++) {
    if (i) cin >> c1 >> c2;
    cin >> a >> b;
    m = a * 100 + (b % 10) * 10 + b / 10;
    if (num[m]) continue;
    num[m]++;
    counter++;
    for (j = 0; j < 4; j++) {
      m = (m % 10) * 1000 + m / 10;
      num[m]++;
    }
  }
  cout << counter << endl;
  return 0;
}
