Scanf.scanf "%d %d" (fun n m ->
    let module S = Set.Make (struct type t = int let compare = compare end) in
    let mat = Array.make_matrix n n (max_int / 1000, S.empty) in
    for i = 0 to n - 1 do mat.(i).(i) <- 0,S.empty done;
    for i = 0 to m - 1 do
        Scanf.scanf " %d %d %d" (fun a b c ->
            let a = a - 1 in let b = b - 1 in
            mat.(a).(b) <- c, S.singleton i;
            mat.(b).(a) <- c, S.singleton i;
        )
    done;
    for k = 0 to n - 1 do
        for i = 0 to n - 1 do
            for j = 0 to n - 1 do
                let d1, s1 = mat.(i).(j) in
                let d2, s2 = mat.(i).(k) in
                let d3, s3 = mat.(k).(j) in
                if d1 > d2 + d3 then mat.(i).(j) <- d2 + d3, S.union s2 s3
            done
        done
    done;
    let edge = Array.make m false in
    for i = 0 to n - 1 do
        for j = 0 to n - 1 do
            let _, s = mat.(i).(j) in
            S.iter (fun v -> edge.(v) <- true) s
        done
    done;
    Array.fold_left (fun acc v -> if v then acc else acc + 1) 0 edge |> Printf.printf "%d\n"
)
