import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	}
} Main public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	} main {
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	} Scanner x=new Scanner(System.in); x new Scanner(System.in) long c=0; c 0 int n=x.nextInt(); n x.nextInt() x.nextInt x String k[]=new String[n]; k new String[n] n for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		} {
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		} String r=x.next(); r x.next() x.next x char a[]=r.toCharArray(); a r.toCharArray() r.toCharArray r Arrays.sort(a) Arrays.sort Arrays a String b=new String(a); b new String(a) k[i]=b k[i] k i b HashMap<String,Integer> m1 = new HashMap<>(); m1 new HashMap<>() for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		} {
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		} if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1); m1.containsKey(k[i]) m1.containsKey m1 k[i] k i m1.put(k[i], m1.get(k[i])+1) m1.put m1 k[i] k i m1.get(k[i])+1 m1.get(k[i]) m1.get m1 k[i] k i 1 m1.put(k[i],1) m1.put m1 k[i] k i 1 for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		} Map.Entry<String,Integer> entry m1.entrySet() m1.entrySet m1 {
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		} {
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		} String s1 = entry.getKey(); s1 entry.getKey() entry.getKey entry long freq = entry.getValue(); freq entry.getValue() entry.getValue entry c+=(freq)*(freq-1)/2 c (freq)*(freq-1)/2 (freq)*(freq-1) (freq) (freq-1) freq 1 2 System.out.println(c) System.out.println System.out System System.out c String args[] args public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	}
} public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	}
} Main
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner x=new Scanner(System.in);
		long c=0;
    	int n=x.nextInt();
		String k[]=new String[n];
		for(int i=0;i<n;i++)
		{
			String r=x.next();
			char a[]=r.toCharArray();
			Arrays.sort(a);
			String b=new String(a);
			k[i]=b;
		}
		HashMap<String,Integer> m1 = new HashMap<>();
		for(int i=0;i<n;i++)
		{
			if(m1.containsKey(k[i])) m1.put(k[i], m1.get(k[i])+1);
			else m1.put(k[i],1);
		}
		for (Map.Entry<String,Integer> entry : m1.entrySet())
		{
            String s1 = entry.getKey();
			long freq = entry.getValue();
			c+=(freq)*(freq-1)/2;
		}
		System.out.println(c);
	}
}