let inf = 10101010101010

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let ed = Array.init m (fun _ -> Scanf.scanf " %d %d %d" (fun a b c -> a-1,b-1,c)) in
  let g = Array.init n (fun _ -> Array.make n inf) in
  for i = 0 to n-1 do g.(i).(i) <- 0 done;
  ed |> Array.iter (fun (u, v, c) -> g.(u).(v) <- c; g.(v).(u) <- c);

  for k = 0 to n-1 do
    for i = 0 to n-1 do
      for j = 0 to n-1 do
        g.(i).(j) <- min g.(i).(j) (g.(i).(k) + g.(k).(j))
  done done done;

  ed |> Array.fold_left (fun a (u,v,c) ->
    if g.(u).(v) < c then a+1 else 0) 0
  |> Printf.printf "%d\n"