//思路:在给定字符串中的所有左移字符串中选择字典序排列最小的一个放到map容器中
//最后map容器的大小就是给定的拥有的不同字符串的大小
#include <iostream>
#include <map>
#include <string>
using namespace std;
#define SIZ 110
map<string, int> Hash;
int minPose(char * s, int n)
{
int p1 = 0, p2 = 1, k = 0;
while(p1 < n && p2 < n && k < n)
{
int cmp = s[(p1 + k) % n] - s[(p2 + k) % n];
if (!cmp)
{
++k;
}
else
{
if (cmp > 0)
{
p1 += k + 1;
}
else
{
p2 += k + 1;
}
k = 0;
p2 += (p1 == p2);
}
}
return min(p1, p2);
}
void rotate(char * s, char * e)
{
if(!s || !e)
{
return;
}
char tmp = 0;
while(s <= e)
{
tmp = *s;
*s = *e;
*e = tmp;
++s;
--e;
}
}
void RotateKBit(char * s, int k)
{
if(!s || !k)
{
return;
}
int n = strlen(s);
k %= n;
rotate(s, s + k -1);
rotate(s + k, s + n -1);
rotate(s, s + n - 1);
}
void GetMin(char * s)
{
char str[SIZ] = {0};
strcpy(str, s);
int n = strlen(s);
int minLoc = minPose(s, n);
RotateKBit(s, minLoc);
}
int findHash(char * str)
{
if (Hash.find(str) == Hash.end())
{
Hash[str] = Hash.size() + 1;
return 0;
}
return 1;
}
int main()
{
int t, i,j;
char str[SIZ];
while (scanf("%d", &t) != EOF)
{
Hash.clear();
while(t--)
{
scanf("%s", str);
GetMin(str);
findHash(str);
}
printf("%d\n", Hash.size());
}
return 0;
}