#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;
#define REP(i, n) for (int i = 0; i < n; i++)

struct edge {
    int u, v, cost;
};

int main() {
    int V, E, d[105][105];
    vector<edge> es;
    cin >> V >> E;
    REP(i, V) fill(d[i], d[i] + V, IINF / 2);
    REP(i, E) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
        es.push_back({a, b, c});
    }
    REP(k, V) REP(i, V) REP(j, V)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int cnt = 0;
    for (auto e : es)
        if (d[e.u][e.v] != e.cost) cnt++;
    cout << cnt << endl;
    return 0;
}
