#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;

    const int inf = 1001001001;
    auto d = make_vec<int>(n, n);
    auto ans = make_vec<int>(n, n);
    fill_v<int>(d, inf);
    rep(i, n) d[i][i] = 0;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        ans[min(a, b)][max(a, b)] = 1;
    }

    auto g = d;
    rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);

    rep(i, n) {
        for (int j = i+1; j < n; ++j) {
            // from i to j
            int now = i;
            int goal = j;
            while (now != goal) {
                rep(k, n) {
                    if (now != k && g[now][k] + d[k][goal] == d[now][goal]) {
                        ans[min(now, k)][max(now, k)] = 0;
                        now = k;
                        break;
                    }
                }
            }
        }
    }

    int res = 0;
    rep(i, n) rep(j, n) res += ans[i][j];
    cout << res << endl;
}
