#include <bits/stdc++.h>

#define REP(i,n) for (int i=0;i<(n);++i)

using namespace std;

int main() {
    constexpr int N_MAX = 100;
    constexpr int C_MAX = 1000;
    constexpr int INF = N_MAX * C_MAX;

    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    vector<vector<int>> dp(N, vector<int>(N, INF));
    REP(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i];
        --b[i];
        dp[a[i]][b[i]] = c[i];
        dp[b[i]][a[i]] = c[i];
    }

    REP(k, N) REP(i, N) REP(j, N) {
        if (dp[i][j] > dp[i][k] + dp[k][j]) {
            dp[i][j] = dp[i][k] + dp[k][j];
        }
    }

    int result = 0;
    REP(i, M) {
        if (dp[a[i]][b[i]] < c[i]) {
            ++result;
        }
    }
    cout << result << endl;

    return 0;
}