module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)
 
let warshall_floyd ( + ) min n d =
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      for k = 0 to n - 1 do
        d.(j).(k) <- min d.(j).(k) (d.(j).(i) + d.(i).(k))
      done
    done
  done
 
let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let es = Array.init m (fun _ ->
    Scanf.scanf "%d %d %d\n" (fun a b c -> (a, b, c))) in
  let dp = Array.make_matrix n n infinity in
  for i = 0 to n - 1 do
    dp.(i).(i) <- 0.
  done;
  Array.iter (fun (a, b, c) ->
    dp.(a - 1).(b - 1) <- float_of_int c;
    dp.(b - 1).(a - 1) <- float_of_int c) es;
  warshall_floyd ( +. ) min n dp;
  Array.to_list es
  |> List.filter (fun (a, b, c) ->
      dp.(a - 1).(b - 1) < float_of_int c)
  |> List.length
  |> Printf.printf "%d\n"