#include<fstream>
#include<cstring>
using namespace std;
char s[35];
int i, n, x;
long long sol;
int ff[ (1 << 16) + 5];
ifstream fin("perechi.in");
ofstream fout("perechi.out");
int main(){
    while(fin>> s){
        n = strlen(s);
        x = 0;
        for(i = 0; i < n; i++){
            if(s[i] >= '0' && s[i] <= '9'){
                x |= ( 1 << (s[i] - '0') );
            }
            else{
                x |= ( 1 << (10 + s[i] - 'A') );
            }
        }
        sol += ff[ (1 << 16) - 1 - x ];
        ff[x]++;
    }
    fout<< sol;
}
