#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<tuple<ll, ll, ll>> edges;
    for (auto &&i: boost::irange(0LL, M)) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        edges.emplace_back(make_tuple(c, a, b));
    }
    vector<vector<ll>> edge_matrix(N, vector<ll>(N, numeric_limits<ll>::max() / 2));
    for (auto &&i: boost::irange(0LL, M)) {
        ll from, to, cost;
        tie(cost, from, to) = edges.at(i);
        edge_matrix.at(from).at(to) = cost;
        swap(from, to);
        edge_matrix.at(from).at(to) = cost;
    }
    auto dp = edge_matrix;
    for (auto &&i: boost::irange(0LL, N)) {
        for (auto &&j: boost::irange(0LL, N)) {
            for (auto &&k: boost::irange(0LL, N)) {
                if (dp.at(i).at(k) + dp.at(k).at(j) < dp.at(i).at(j)) {
                    dp.at(i).at(j) = dp.at(i).at(k) + dp.at(k).at(j);
                }
            }
        }
    }
    ll count{0};
    for (auto &&i: boost::irange(0LL, M)){
        ll from, to, cost;
        tie(cost, from, to) = edges.at(i);
        if (dp.at(from).at(to) > dp.at(from).at(to)){
            count ++;
        }
    }
    cout << count;
}
