#include <bits/stdc++.h>
int cnt[6667];
int main() {
  int n, t = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    if (i) {
      char tmp[256];
      scanf("%s", tmp);
    }
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    int k = a * 100 + (b % 10) * 10 + b / 10;
    if (cnt[k]) continue;
    t++;
    for (int w = 0; w < 4; ++w) {
      cnt[k] = 1;
      k = (k % 1000) * 10 + k / 1000;
    }
  }
  printf("%d\n", t);
  return 0;
}
