#include <iostream>
#include <vector>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    VVI e(n,VI(n,INF));
    REP(i,n) e[i][i] = 0;
    while (m--){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        e[a][b] = c;
        e[b][a] = c;
    }
    VVI d(e);    
    REP(i,n) REP(j,n) REP(k,n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

    int ans = 0;
    REP(i,n) REP(j,i) if (e[i][j] != INF && e[i][j] > d[i][j]) ans++;
    cout << ans << endl;

    return 0;
}