#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 105;
int n, m, ans, a, b, c;
vector<int> M[2010]; // at most 2000 edges
bool good[1010];
vector<int> e[N];
int dist[N];

auto cmp = [&](int a, int b){
    int f1 = M[a][0], w1 = M[a][2];
    int f2 = M[b][0], w2 = M[b][2];
    int aa = dist[f1] + w1;
    int bb = dist[f2] + w2;
    return aa >= bb;
};
void run(int x) {
    memset(dist, 0x3f, N);
    priority_queue<int, vector<int>, decltype(cmp)> que(cmp);
    dist[x] = 0;
    for (auto z : e[x]) {
        que.push(z);
    }
    while (!que.empty()) {
        int y = que.top();
        que.pop();
        int f = M[y][0], t = M[y][1], w = M[y][2];
        int ndist = dist[f] + w;
        if (dist[t] > ndist) {
            dist[t] = ndist;
            good[y % m] = true;
            for (int z : e[t]) {
                que.push(z);
            }
        } else if (dist[t] == ndist) {
            good[y % m] = true;
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b >> c;
        M[i] = {a, b, c};
        M[m + i] = {b, a, c};
        e[a].push_back(i);
        e[b].push_back(i + m);
    }
    for (int i = 1; i <= n; ++i) {
        run(i);
    }
    for (int i = 0; i < m; ++i) {
        if (good[i])
            ++ans;
    }

    cout << m - ans << endl;
    return 0;
}
