public static void main ( String [ ] args ) {
  Scanner scanner = new Scanner ( System . in ) ;
  int N = scanner . nextInt ( ) ;
  int M = scanner . nextInt ( ) ;
  int [ ] [ ] edges = new int [ M ] [ 3 ] ;
  int [ ] [ ] dist = new int [ N ] [ N ] ;
  int INF = 100_000_000 ;
  for ( int i = 0 ;
  i < N ;
  i ++ ) for ( int j = 0 ;
  j < N ;
  j ++ ) dist [ i ] [ j ] = INF ;
  for ( int i = 0 ;
  i < M ;
  i ++ ) {
    int a = scanner . nextInt ( ) - 1 ;
    int b = scanner . nextInt ( ) - 1 ;
    int c = scanner . nextInt ( ) ;
    edges [ i ] [ 0 ] = a ;
    edges [ i ] [ 1 ] = b ;
    edges [ i ] [ 2 ] = c ;
    dist [ a ] [ b ] = dist [ b ] [ a ] = c ;
  }
  for ( int k = 0 ;
  k < N ;
  k ++ ) for ( int i = 0 ;
  i < N ;
  i ++ ) for ( int j = 0 ;
  j < N ;
  j ++ ) if ( dist [ i ] [ j ] > dist [ i ] [ k ] + dist [ k ] [ j ] ) dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] ;
  int num = 0 ;
  for ( int i = 0 ;
  i < M ;
  i ++ ) {
    int a = edges [ i ] [ 0 ] ;
    int b = edges [ i ] [ 1 ] ;
    int c = edges [ i ] [ 2 ] ;
    if ( dist [ a ] [ b ] == c ) num ++ ;
  }
  System . out . println ( M - num ) ;
}

public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int [ ] [ ] edges = new int [ M ] [ 3 ] ; int [ ] [ ] dist = new int [ N ] [ N ] ; int INF = 100_000_000 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) dist [ i ] [ j ] = INF ; for ( int i = 0 ; i < M ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; int c = scanner . nextInt ( ) ; edges [ i ] [ 0 ] = a ; edges [ i ] [ 1 ] = b ; edges [ i ] [ 2 ] = c ; dist [ a ] [ b ] = dist [ b ] [ a ] = c ; } for ( int k = 0 ; k < N ; k ++ ) for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < N ; j ++ ) if ( dist [ i ] [ j ] > dist [ i ] [ k ] + dist [ k ] [ j ] ) dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] ; int num = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int a = edges [ i ] [ 0 ] ; int b = edges [ i ] [ 1 ] ; int c = edges [ i ] [ 2 ] ; if ( dist [ a ] [ b ] == c ) num ++ ; } System . out . println ( M - num ) ; }
(method_declaration (modifiers) type: (void_type) name: (identifier) parameters: (formal_parameters (formal_parameter type: (array_type element: (type_identifier) dimensions: (dimensions)) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (field_access object: (identifier) field: (identifier)))))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (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)) dimensions: (dimensions_expr (decimal_integer_literal))))) (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)) dimensions: (dimensions_expr (identifier))))) (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: (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: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (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: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)) right: (identifier))) (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (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: (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: (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: (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))) consequence: (expression_statement (assignment_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier))))))))) (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: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (array_access array: (array_access array: (identifier) index: (identifier)) index: (decimal_integer_literal)))) (if_statement condition: (parenthesized_expression (binary_expression left: (array_access array: (array_access array: (identifier) index: (identifier)) index: (identifier)) right: (identifier))) consequence: (expression_statement (update_expression (identifier)))))) (expression_statement (method_invocation object: (field_access object: (identifier) field: (identifier)) name: (identifier) arguments: (argument_list (binary_expression left: (identifier) right: (identifier)))))))