type 'a set =
  | Empty
  | Singleton of 'a
  | Union of 'a set * 'a set

let rec make_intset acc = function
  | Empty -> ()
  | Singleton x -> acc.(x) <- true
  | Union (s, t) -> make_intset acc s; make_intset acc t

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 dp = Array.make_matrix n n (infinity, Empty) in
  for i = 0 to n - 1 do
    dp.(i).(i) <- (0., Empty)
  done;
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d\n" (fun a b c ->
      dp.(a - 1).(b - 1) <- (float_of_int c, Singleton i);
      dp.(b - 1).(a - 1) <- (float_of_int c, Singleton i))
  done;
  warshall_floyd
    (fun (d, es) (d', es') -> (d +. d', Union (es, es')))
    (fun (d, es) (d', es') ->
      match compare d d' with
      | -1 -> (d, es)
      | 0  -> (d, Union (es, es'))
      | 1  -> (d', es')) n dp;
  let bs = Array.make n false in
  Array.iter (Array.iter (fun (_, es) -> make_intset bs es)) dp;
  Array.to_list bs
  |> List.filter (fun b -> not b)
  |> List.length
  |> Printf.printf "%d\n"