#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}



bool used[100][100];

// O(V^3)
void warshall_floyd(int n, vector<vector<int> > &g) {
    for(int k = 0; k < n; ++k)
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < n; ++j) {
                if(chmin(g[i][j], g[i][k] + g[k][j])) {
                    used[i][j] = false;
                    used[i][k] = true;
                    used[k][j] = true;
                }
            }
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    vector<vector<int> > g(n,vector<int>(n,1e9));
    int as[100], bs[100];
    for(int i=0; i < m; ++i){
        int a,b,c;
        cin >> a >> b >> c;
        --a; --b;
        g[a][b] = c;
        g[b][a] = c;
        as[i] = a;
        bs[i] = b;
    }
    warshall_floyd(n, g);

    int ans = 0;
    for(int i=0; i < m; ++i) {
        if(!used[as[i]][bs[i]]) ++ans;
    }

    cout << ans << '\n';
    return 0;
}