/* 采用排序+哈希可以快速解决此问题 */
#include <bits/stdc++.h>
using namespace std;

int n = 0;
string calc(string s){
    vector<string> v;
    int m = s.length();
    for (int i = 0; i < m; i++) {
        string tmp = s;
        for (int j = 0; j < m; j++) {
            tmp[j] = s[(j + i) % m];
        }
        v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    return v[0];
}

int main() {
    set<string> s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string x;
        cin >> x;
        s.insert(calc(x));
    }
    cout << s.size() << endl;
}