#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;




template<typename T> T chmax(T& a, const T& b) {return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b) {return a = (a < b ? a : b);}

//有向、無向グラフ共通クラス(隣接リスト)
struct Graph {
    int n;
    using WEIGHT_TYPE = ll;
    static const WEIGHT_TYPE INF = 1e18;
    struct Edge {
        int to;
        WEIGHT_TYPE weight;
    };
    struct Edge2 {
        int from;
        int to;
        WEIGHT_TYPE weight;
    };
    vector<vector<Edge>> es;
    Graph(int n) : n(n), es(n) {}

    // dijkstra O(E log V)
    vector<WEIGHT_TYPE> dijkstra(int s) {
        vector<WEIGHT_TYPE> d(n, INF);
        d[s] = 0;
        using P = pair<WEIGHT_TYPE, int>;
        priority_queue<P, vector<P>, greater<P> > q;
        q.push({0LL, s});
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            int cur = p.se;
            auto cost = p.fi;
            if (d[cur] < p.fi) continue;
            for (auto& e : es[cur]) {
                int to = e.to;
                auto dist = e.weight + cost;
                if (dist < d[to]) {
                    d[to] = dist;
                    q.push({dist, to});
                }
            }
        }
        return d;
    }
    // warshall_floyd O(n^3)
    vector<vector<WEIGHT_TYPE>> warshall_floyd() {
        vector<vector<WEIGHT_TYPE>> d(n, vector<WEIGHT_TYPE>(n, INF));
        rep(i, n) d[i][i] = 0LL;
        rep(i, n) for (auto && e : es[i]) {
            int j = e.to;
            chmin(d[i][j], e.weight);
        }
        rep(k, n) rep(i, n) rep(j, n) {
            chmin(d[i][j], d[i][k] + d[k][j]);
        }
        return d;
    }
};

// 無向グラフ
struct GraphUD : public Graph {
    GraphUD(int n) : Graph(n) {}
    void add_edge(int from, int to, WEIGHT_TYPE weight) {
        es[from].push_back({to, weight});
        es[to].push_back({from, weight});
    }
    vector<Edge2> getEdge2() {
        vector<Edge2> ret;
        rep(i, n) for (auto && e : es[i]) {
            if (i < e.to) ret.push_back({i, e.to, e.weight});
        }
        return ret;
    }
};


// 有向グラフ
struct GraphD : public Graph {
    GraphD(int n) : Graph(n) {}
    void add_edge(int from, int to, WEIGHT_TYPE weight) {
        es[from].push_back({to, weight});
    }
    vector<Edge2> getEdge2() {
        vector<Edge2> ret;
        rep(i, n) for (auto && e : es[i]) {
            ret.push_back({i, e.to, e.weight});
        }
        return ret;
    }
    GraphD getReverseGraph() {
        GraphD g(n);
        rep(i, n) for (auto && e : es[i]) {
            g.add_edge(e.to, i, e.weight);
        }
        return g;
    }
    vector<vector<int>> scc() {
        vector<vector<int>> res;
        vector<int> cmp(n);
        vector<int> vs;
        vector<vector<int>> r_es(n);
        rep(i, n) for (auto && e : es[i]) {
            int j = e.to;
            r_es[j].push_back(i);
        }

        vector<bool> used(n);
        function<void(int)> dfs = [&](int v) {
            used[v] = true;
            for (auto && e : es[v]) {
                int to = e.to;
                if (!used[to]) dfs(to);
            }
            vs.push_back(v);
        };
        function<void(int, int)> rdfs = [&](int v, int k) {
            used[v] = true;
            cmp[v] = k;
            for (auto && to : r_es[v]) {
                if (!used[to]) rdfs(to, k);
            }
        };

        fill(all(used), 0);
        vs.clear();
        for (int v = 0; v < n; v++) {
            if (!used[v]) dfs(v);
        }
        fill(all(used), 0);
        int k = 0;
        for (int i = vs.size() - 1; i >= 0; i--) {
            if (!used[vs[i]]) rdfs(vs[i], k++);
        }
        res.clear();
        res.resize(k);
        for (int i = 0; i < n; i++) {
            res[cmp[i]].push_back(i);
        }
        return res;
    }
};


int main() {
    int n, m;
    cin >> n >> m;
    GraphUD g(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        g.add_edge(a - 1, b - 1, c);
    }
    auto d = g.warshall_floyd();
    int ans = 0;
    auto es = g.getEdge2();
    for (auto && e : es) {
        bool f = false;
        auto x = e.from;
        auto y = e.to;
        auto z = e.weight;
        rep(i, n) rep(j, i) {
            f |= (d[i][j] == min(d[i][x] + d[y][j], d[i][y] + d[x][j]) + z);
        }
        if(!f) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384