#include <bits/stdc++.h>
using namespace std;
string s[10001][5][5];
string a[10001][5];
int main(){
	int n;
	cin >>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=4;j++)
		{
			cin >>a[i][j];
		}
	}
	int cnt=0;
	int m=1;
	for(int i=1;i<=4;i++)
	{
		for(int j=1;j<=4;j++)
		{
			s[m][i][j]=a[i][j];
		}
	}
	for(int i=5;i<=n;i+=4)
	{
		bool flag=false;
		for(int i1=0;i1<4;i1++)
		{
			for(int j=1;j<=4;j++)
			{
				for(int l=1;l<=m;l++)
				{
					if(s[l][i1+1][j]!=a[i+i1][j])
					{
						flag=true;
					}
				}
			}
		}	
		if(flag==true)
		{
			m++;
			cnt++;
				for(int i1=0;i1<4;i1++)
				{
					for(int j=1;j<=4;j++)
					{
						for(int l=1;l<=m;l++)
						{
							s[l][i1+1][j]=a[i+i1][j];
						}
					}
				}	
		}
	} 
	cout<<cnt;
	return 0;
}