use std::cmp::min;

fn input<T>() -> T
    where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

static INF: i64 = 100_000_000;

fn main() {
    let n = input::<usize>();
    let m = input::<usize>();
    let v = (0..m)
        .map(|_| (input::<usize>()-1, input::<usize>()-1, input()))
        .collect::<Vec<(_, _, i64)>>();

    let mut d = vec![vec![INF; 100]; 100];


    for  i in 0..n {
        d[i][i] = 0;
    }

    for &(a, b, c) in &v {
        d[a][b] = min(d[a][b], c);
        d[b][a] = min(d[b][a], c);
    }

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

    let mut ans = m;
    for &(a, b, c) in &v {
        let mut  shortest = false;
        for j in 0..n {
            if d[j][a] + c == d[j][b] {
                shortest = true;
            }
        }
        if shortest {
            ans-=1;
        }
    }
    println!("{}", ans);
}
