#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;

int main() {
    int a[1000], b[1000], c[1000];
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int i = 0; i < m; i++) {
        a[i]--;
        b[i]--;
    }
    int l[100][128] = {};
    for (int i = 0; i < m; i++) {
        l[a[i]][b[i]] = l[b[i]][a[i]] = c[i];
    }

    int k = 0;
    for (int i = 0; i < m; i++) {
        int d[100];
        for (int v = 0; v < n; v++) d[v] = INT_MAX;
        d[a[i]] = 0;
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> q;
        q.push({ a[i], 0 });
        
        for (; !q.empty();) {
            auto t = q.top();
            q.pop();
            if (t.first == b[i]) {
                if (d[b[i]] < c[i]) k++;
                break;
            }

            for (int v = 0; v < 100; v++) {
                int d4 = l[t.first][v];
                if (d4 == 0) continue;
                d4 += t.second;
                if (d[v] <= d4) continue;
                if (c[i] <= d4 && v != b[i]) continue;
                d[v] = d4;
                q.push({ v, d4 });
            }
        }
    }

    cout << k << endl;
    return 0;
}
