unittest
{
	assert( [ "3", "acornistnt", "peanutbomb", "constraint" ].parse.expand.solve == 1 );
	assert( [ "2", "oneplustwo", "ninemodsix" ].parse.expand.solve == 0 );
	assert( [ "5", "abaaaaaaaa", "oneplustwo", "aaaaaaaaba", "twoplusone", "aaaabaaaaa" ].parse.expand.solve == 4 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( ss );
}

auto solve( dchar[][] ss )
{
	foreach( ref s; ss )
	{
		s.sort();
	}
	auto ans = 0L;
	foreach( g; ss.sort().group )
	{
		auto c = cast( long ) g[ 1 ];
		ans += c * ( c - 1 ) / 2;
	}
	return ans;
}
