#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void normalizza(char *s){
    char t[26]={0}, c='a';
    int i, l=strlen(s);
    printf("%s -> ", s);
    for(i=0; i<l; i++)
        if (t[s[i]-'a']!=0) s[i]=t[s[i]-'a'];
        else {
            t[s[i]-'a']=c;
            s[i]=c;
            c++;
        }
    printf("%s\n", s);
}

int main(int argc, char **argv){
    int n,i,j, count=0;
    char **s;
    /* Acquisizione dati */
    FILE *fin=fopen(argv[1], "r");
    fscanf(fin, "%d\n", &n);
    s=malloc(sizeof(char *)*n);
    for(i=0; i<n; i++){
        char buf[2000]={0};
        fscanf(fin, "%s", buf);
        s[i]=strdup(buf);
    }
    fclose(fin);
    /* Normalizzazione */
    for(i=0; i<n; i++)
        normalizza(s[i]);
    /* Conteggio simili */
    for(i=0; i<n; i++)
        for(j=i+1; j<n; j++)
            if (strcmp(s[i],s[j])==0) count++;
    printf("%d\n", count);
}
