use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        m: usize,
        abc: [(usize, usize, i64); m],
    }
    let mut map = vec![vec![std::i64::MAX / 2; n + 1]; n + 1];
    for i in 1..n + 1 {
        map[i][i] = 0;
    }

    for i in 0..abc.len() {
        let x = abc[i];
        map[x.0][x.1] = x.2;
        map[x.1][x.0] = x.2;
    }

    for k in 1..n + 1 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
            }
        }
    }

    let mut v = vec![false; m];
    for i in 1..n + 1 {
        for j in 1..n + 1 {
            for k in 0..m {
                let mut x = abc[k];
                if map[i][j] == map[i][x.0] + map[x.1][j] + 1 {
                    v[k] = true;
                }
            }
        }
    }
    println!("{}", v.iter().filter(|&x| *x == false).count());
}
