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

constexpr int INF = 1e9;

struct edge {
    int from, to, cost;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N, vector<int>(N, INF));
    vector<edge> es(M);
    for(int i=0; i<M; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a][b] = g[b][a] = c;
        es.push_back((edge){a, b, c});
    }
    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 res = 0;
    for(auto e : es) {
        if(g[e.from][e.to] < e.cost) {
            res++;
        }
    }
    cout << res << endl;
}
