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

const int INF = 1e9;

int n;
int d[102][102];

void WarshallFloyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[j][k]);
            }
        }
    }
}

int main()
{
    int m;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        fill(d[i], d[i] + n, INF);
    }
    int a[1005], b[1005], c[1005];
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    WarshallFloyd();
    int ans = 0;
    for(int i = 0; i < m; i++){
        if(d[a[i]][b[i]] < c[i]) ans++;
    }
    cout << ans << endl;
}
