#include<bits/stdc++.h>
using namespace std;

#define INF 10000000

int main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > dist(n, vector<int> (n, INF));
    for(int i = 0; i < n; i++) dist[i][i] = 0;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(m);

    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i];
    
        dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }


    //わー
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < m; i++){
        if(dist[a[i]][b[i]] == c[i]) ans++;
    }

    cout << m - ans << endl;
    return 0;
}#include<bits/stdc++.h>
using namespace std;

#define INF 10000000

int main(){

    int n, m; cin >> n >> m;
    vector<vector<int> > dist(n, vector<int> (n, INF));
    for(int i = 0; i < n; i++) dist[i][i] = 0;
    vector<int> a(m);
    vector<int> b(m);
    vector<int> c(m);

    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        c[i];
    
        dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }


    //わー
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }


    int ans = 0;
    for(int i = 0; i < m; i++){
        if(dist[a[i]][b[i]] == c[i]) ans++;
    }

    cout << m - ans << endl;
    return 0;
}