#include <iostream>
#include <vector>
using namespace std;

void warshall_floyd(int n, vector<vector<int> > &g) {
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<vector<int> > g(n,vector<int>(n, 1e9));
    int a[1010], b[1010], c[1010];
    for(int i=0; i < m; ++i){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
        g[a[i]][b[i]] = c[i];
        g[b[i]][a[i]] = c[i];
    }
    for(int i=0;i<n;++i) g[i][i] = 0;
    warshall_floyd(n, g);

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

    cout << ans << '\n';
    return 0;
}