let n, m, ds = Scanf.scanf "%d %d" @@ fun n m -> Array.(n, m, make_matrix n n (1 lsl 40))
let es = Array.init m @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun a b t -> ds.(a - 1).(b - 1) <- t; ds.(b - 1).(a - 1) <- t; a - 1, b - 1, t
let _ = Array.(iteri (fun i d -> iteri (fun j _ -> if i = j then d.(j) <- 0) d)) ds; for k = 0 to n - 1 do for i = 0 to n - 1 do for j = 0 to n - 1 do ds.(i).(j) <- min ds.(i).(j) @@ ds.(i).(k) + ds.(k).(j) done done done;
  Array.(fold_left (fun r (i, j, t) -> if ds |> to_list |> List.exists (fun s -> s.(i) + t = s.(j) || s.(j) + t = s.(i)) then r - 1 else r) m es) |> Printf.printf "%d\n"