public static void main ( String [ ] args ) throws IOException {
  BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;
  StringBuilder sb = new StringBuilder ( ) ;
  String [ ] str = br . readLine ( ) . split ( " " ) ;
  int n = Integer . parseInt ( str [ 0 ] ) , k = Integer . parseInt ( str [ 1 ] ) ;
  String [ ] data = new String [ n ] ;
  char [ ] vals = new char [ ] {
    'S' , 'E' , 'T' };
    HashMap < String , Integer > hm = new HashMap < > ( ) ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      data [ i ] = br . readLine ( ) ;
      hm . computeIfPresent ( data [ i ] , ( key , val ) -> val += 1 ) ;
      hm . putIfAbsent ( data [ i ] , 1 ) ;
    }
    int cnt = 0 ;
    for ( int i = 0 ;
    i < n ;
    i ++ ) {
      String s1 = data [ i ] ;
      for ( int j = i + 1 ;
      j < n ;
      j ++ ) {
        String s2 = data [ j ] ;
        String toFind ;
        char [ ] c1 = new char [ k ] ;
        for ( int z = 0 ;
        z < k ;
        z ++ ) {
          char s1c = s1 . charAt ( z ) , s2c = s2 . charAt ( z ) ;
          if ( s1c == s2c ) c1 [ z ] = s1c ;
          else {
            for ( int z1 = 0 ;
            z1 < 3 ;
            z1 ++ ) {
              if ( s1c != vals [ z1 ] && s2c != vals [ z1 ] ) {
                c1 [ z ] = vals [ z1 ] ;
              }
            }
          }
        }
        toFind = String . valueOf ( c1 ) ;
        if ( hm . containsKey ( toFind ) ) {
          cnt += hm . get ( toFind ) ;
          if ( toFind . equals ( data [ i ] ) ) cnt -= 2 ;
        }
      }
    }
    System . out . println ( cnt / 3 ) ;
  }
  
public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( str [ 0 ] ) , k = Integer . parseInt ( str [ 1 ] ) ; String [ ] data = new String [ n ] ; char [ ] vals = new char [ ] { ' S ' , ' E ' , ' T ' } ; HashMap < String , Integer > hm = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = br . readLine ( ) ; hm . computeIfPresent ( data [ i ] , ( key , val ) -> val += 1 ) ; hm . putIfAbsent ( data [ i ] , 1 ) ; } int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String s1 = data [ i ] ; for ( int j = i + 1 ; j < n ; j ++ ) { String s2 = data [ j ] ; String toFind ; char [ ] c1 = new char [ k ] ; for ( int z = 0 ; z < k ; z ++ ) { char s1c = s1 . charAt ( z ) , s2c = s2 . charAt ( z ) ; if ( s1c == s2c ) c1 [ z ] = s1c ; else { for ( int z1 = 0 ; z1 < 3 ; z1 ++ ) { if ( s1c != vals [ z1 ] && s2c != vals [ z1 ] ) { c1 [ z ] = vals [ z1 ] ; } } } } toFind = String . valueOf ( c1 ) ; if ( hm . containsKey ( toFind ) ) { cnt += hm . get ( toFind ) ; if ( toFind . equals ( data [ i ] ) ) cnt -= 2 ; } } } System . out . println ( cnt / 3 ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) (throws (type_identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list)))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) name: (identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal))))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (decimal_integer_literal)))))) (local_variable_declaration type: (array_type element: (type_identifier) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (type_identifier) dimensions: (dimensions_expr (identifier))))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions) value: (array_initializer (character_literal) (character_literal) (character_literal))))) (local_variable_declaration type: (generic_type (type_identifier) (type_arguments (type_identifier) (type_identifier))) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (generic_type (type_identifier) (type_arguments)) arguments: (argument_list)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (lambda_expression parameters: (inferred_parameters (identifier) (identifier)) body: (assignment_expression left: (identifier) right: (decimal_integer_literal)))))) (expression_statement (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier)) (decimal_integer_literal)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (identifier) right: (decimal_integer_literal)))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (array_access array: (identifier) index: (identifier)))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (local_variable_declaration type: (array_type element: (integral_type) dimensions: (dimensions)) declarator: (variable_declarator name: (identifier) value: (array_creation_expression type: (integral_type) dimensions: (dimensions_expr (identifier))))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (identifier)) update: (update_expression (identifier)) body: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (binary_expression left: (identifier) right: (identifier))) consequence: (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (identifier))) alternative: (block (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (decimal_integer_literal)) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))) right: (binary_expression left: (identifier) right: (array_access array: (identifier) index: (identifier))))) consequence: (block (expression_statement (assignment_expression left: (array_access array: (identifier) index: (identifier)) right: (array_access array: (identifier) index: (identifier)))))))))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier)))) consequence: (block (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (if_statement condition: (parenthesized_expression (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (array_access array: (identifier) index: (identifier))))) consequence: (expression_statement (assignment_expression left: (identifier) right: (decimal_integer_literal)))))))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (decimal_integer_literal)))))))