#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e+9;
const int MAX_N = 2e5 + 7;
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  int mark[10000] = {false};
  for (int i = 0; i < n; i++) {
    string s;
    if (i > 0) cin >> s;
    int a, b;
    cin >> a >> b;
    int k = a * 100 + b;
    if (mark[k]) continue;
    cnt++;
    for (int j = 0; j < 4; j++) {
      mark[k] = true;
      int w = a % 10, x = b % 10, y = a / 10, z = b / 10;
      a = w * 10 + x, b = y * 10 + z;
      k = a * 100 + b;
    }
  }
  cout << cnt;
  return 0;
}
