#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    int res = 0;
    vector<int> a(m), b(m), c(m);
    vector<vector<int> > g(n, vector<int>(n, Inf));
    rep (i, n) g[i][i] = 0;
    rep (i, m) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i], --b[i];
        g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
    }
    rep (k, n) rep (i, n) rep (j, n) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    rep (i, m) {
        if (g[a[i]][b[i]] < c[i]) res++;
    }
    cout << res << endl;
    
    return 0;
}

