#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(dead_code)]
#![allow(unused_variables)]

use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
use std::mem::swap;
use std::io::prelude::*; // input()

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: usize = 100_000;

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

    let mut d = vec![vec![INF; 100]; 100];
    for i in 0..n {
        d[i][i] = 0; } 
    for &(a, b, c) in &abc {
        d[a][b] = min(d[a][b], c);
        d[b][a] = min(d[b][a], c);
    }

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

    let mut ans = m;

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