#!/bin/bash

read n

declare -A arr;
for i in `seq 1 $n`; do
    read s
    s=$(
	for c in $( echo $s | sed -E "s/(.)/\1 /g");
	do
	    echo $c
	done | sort | tr -d "\n"
     )
    if [ -z "${arr[$s]}" ]; then
	arr[$s]=1
    else
	arr[$s]=$((${arr[$s]}+1))
    fi
done

cnt=0
for c in ${arr[@]};
do
    cnt=$( echo "$cnt + ($c*($c-1))/2" | bc)
done
echo $cnt
