#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int N, M;
vector<vector<int>> d(100, vector<int>(100, INF));

void warshall_floyd() {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    return;
}

int main() {
    cin >> N >> M;
    vector<int> a(M), b(M), c(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    warshall_floyd();

    int count = 0;
    for (int i = 0; i < M; i++) {
        if (c[i] > d[a[i]][b[i]]) {
            count++;
        }
    }
    cout << count << endl;
}