#include <bits/stdc++.h>
using namespace std;
int getnum() {
  char ch = ' ';
  while (ch < '1' || ch > '9') {
    cin >> ch;
  }
  return ch - '0';
}
int N;
bool boo[10][10][10][10];
int main() {
  scanf("%d", &N);
  int num1, num2, num3, num4, answer = 0;
  int i;
  for (i = 1; i <= N; i++) {
    num1 = getnum();
    num2 = getnum();
    num3 = getnum();
    num4 = getnum();
    if (!boo[num1][num2][num4][num3]) {
      answer++;
      boo[num1][num2][num4][num3] = 1;
      boo[num2][num4][num3][num1] = 1;
      boo[num4][num3][num1][num2] = 1;
      boo[num3][num1][num2][num4] = 1;
    }
  }
  printf("%d", answer);
}
