#include<bits/stdc++.h> 
using namespace std; 
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;} 
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(i,b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(i,b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
//#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back 
#define MOD                 1000000007 
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}
bool isSmaller(string str1, string str2) 
{ 

    // Calculate lengths of both string 

    int n1 = str1.length(), n2 = str2.length(); 

  

    if (n1 < n2) 

        return true; 

    if (n2 > n1) 

        return false; 

  

    for (int i=0; i<n1; i++) 

    { 

        if (str1[i] < str2[i]) 

            return true; 

        else if (str1[i] > str2[i]) 

            return false; 

    } 

    return false; 
} 

  
// Function for finding difference of larger numbers 
string fdiff(string str1, string str2) 
{ 

    // Before proceeding further, make sure str1 

    // is not smaller 

   // if (isSmaller(str1, str2))     swap(str1, str2); 

 
    // Take an empty string for storing result 

    string str = ""; 

  

    // Calculate lengths of both string 

    int n1 = str1.length(), n2 = str2.length(); 

    int diff = n1 - n2; 

  

    // Initially take carry zero 

    int carry = 0; 

  

    // Traverse from end of both strings 

    for (int i=n2-1; i>=0; i--) 

    { 

        // Do school mathematics, compute difference of 

        // current digits and carry 

        int sub = ((str1[i+diff]-'0') - 

                   (str2[i]-'0') - 

                   carry); 

        if (sub < 0) 

        { 

            sub = sub+10; 

            carry = 1; 

        } 

        else

            carry = 0; 

  

        str.push_back(sub + '0'); 

    } 

  

    // subtract remaining digits of str1[] 

    for (int i=n1-n2-1; i>=0; i--) 

    { 

        if (str1[i]=='0' && carry) 

        { 

            str.push_back('9'); 

            continue; 

        } 

        int sub = ((str1[i]-'0') - carry); 

        if (i>0 || sub>0) // remove preceding 0's 

            str.push_back(sub+'0'); 

        carry = 0; 

  

    } 

  

    // reverse resultant string 

    reverse(str.begin(), str.end()); 

  

    return str; 
}
string fsum(string str1, string str2) 
{ 

    if (str1.length() > str2.length()) 

        swap(str1, str2); 

    string str = ""; 

    int n1 = str1.length(), n2 = str2.length(); 

    int diff = n2 - n1; 

    int carry = 0; 

    for (int i=n1-1; i>=0; i--) 

    { 

        int sum = ((str1[i]-'0') + 

                   (str2[i+diff]-'0') + 

                   carry); 

        str.push_back(sum%10 + '0'); 

        carry = sum/10; 

    } 

    for (int i=n2-n1-1; i>=0; i--) 

    { int sum = ((str2[i]-'0')+carry); 

        str.push_back(sum%10 + '0'); 

        carry = sum/10; 

    } 

    if (carry) 

        str.push_back(carry+'0'); 

    reverse(str.begin(), str.end()); 

  

    return str; 
} 
int main()
{ 
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
  //  start_routine();
    ll a,b;
    ll n;
    cin>>n;
    string s[n];
    unordered_map<string , ll> um; 
    loop(i,0,n)
    {
        cin>>s[i]; 
        sort(s[i].begin(),s[i].end());
        um[s[i]]++; 
    }
    ll ans=0;
    for(auto i:um)
     {
         ll k=i.second;
         ans+=((k*(k-1))/2);
     }
     cout<<ans<<"\n";
 return 0;
}

Measured memory_bytes: 16036