#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

void dijkstra(lint s, vec<vec<plint>>& adj, vec<vec<lint>>& d, vec<vec<lint>>& parent) {
    vec<lint>& cur_d = d.at(s);
    vec<lint>& cur_p = parent.at(s);
    cur_d.at(s) = 0;
    priority_queue<plint, vec<plint>, greater<plint>> que;
    que.emplace(0, s);
    while (!que.empty()) {
        lint node = que.top().second, dist = que.top().first;
        que.pop();
        if (dist > cur_d.at(node)) continue;
        for (const auto nei_with_c : adj.at(node)) {
            lint neighbor = nei_with_c.first, cost = nei_with_c.second;
            if (dist + cost < cur_d.at(neighbor)) {
                cur_d.at(neighbor) = dist + cost;
                cur_p.at(neighbor) = node;
                que.emplace(dist + cost, neighbor);
            }
        }
    }
    return;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M;
    cin >> N >> M;
    vec<vec<plint>> adj(N, vec<plint>());
    range(i, 0, M) {
        lint a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        adj.at(a).emplace_back(b, c);
        adj.at(b).emplace_back(a, c);
    }
    vec<vec<lint>> d(N, vec<lint>(N, 1LL << 50));
    vec<vec<lint>> parent(N, vec<lint>(N, -1));
    range(s, 0, N) dijkstra(s, adj, d, parent);
    set<plint> appeared;
    range(i, 0, N) range(j, 0, N) {
        lint p = parent.at(i).at(j);
        if (p != -1) {
            appeared.emplace(j, p);
            appeared.emplace(p, j);
        }
    }
    // cout << appeared << "\n";
    cout << M - appeared.size() / 2 << "\n";
}

Measured memory_bytes: 512