#include <stdio.h>
#import <Foundation/Foundation.h>
 
int main() {
 
  int N;
  scanf("%d", &N);
  
  NSInteger i;
  NSMutableArray *strings = [[NSMutableArray alloc] init];
  NSMutableDictionary *table = [[NSMutableDictionary alloc] init];
 
  NSInteger result = 0;
  for(i=0;i<N;i++) {
    char *str;
    scanf("%s", str);
    sortedWithCharacter(str, 0, 9);
    NSString *sortedStr = [NSString stringWithCString:str  encoding:NSUTF8StringEncoding];
    if ([table objectForKey: sortedStr] != nil) {
        NSNumber *count = [NSNumber numberWithInt: [[table objectForKey: sortedStr] integerValue] + 1];
        [table setObject: count forKey: sortedStr];
    } else {
        [table setObject: [NSNumber numberWithInt:1] forKey: sortedStr];
    }
  }
 
  for (NSNumber *count in [table allValues]) {
      result += (float)([count integerValue] * ([count integerValue] - 1)) / 2;
  }
  
  printf("%d", result);
  return 0;
}
 
void sortedWithCharacter(char *character, int left, int right) {
    if (left >= right) {
        return;
    }
    
    int pivot = (left + right) / 2;
    
    int p=left;
    int q=right;
    
    while (p <= q) {
        while(p < 10 && character[p] <= character[pivot]) p++;
        while(q >= 0 && character[q] > character[pivot]) q--;
        
        if(p<q) {
            char tmp = character[p];
            character[p] = character[q];
            character[q] = tmp;
        }
        p ++;
        q --;
    }
    
    sortedWithCharacter(character, left, q);
    sortedWithCharacter(character, p, right);    
}