#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, m;
int a[1010], b[1010], c[1010];
int d[110][110];
int prev[110][110];

const int INF = 1e7;

void init(int n){
    rep(i, 0, n){
        rep(j, 0, n){
            d[i][j] = INF;
            prev[i][j] = i;
            if(i == j) d[i][j] = 0;
        }
    }
}

void warshall_floyd(){
    rep(k, 0, n){
        rep(i, 0, n){
            rep(j, 0, n){
                if(d[i][k] + d[k][j] < d[i][j]){
                    d[i][j] = d[i][k] + d[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
}

int f[110][110];

void path(int s, int g){
    vector<int> pt;
    for(int i = g; i != s; i = prev[s][i]){
        // st.insert(i);
        pt. push_back(i);
    }
    reverse(all(pt));
    int now = s;
    rep(i, 0, pt.size()){
        f[now][pt[i]] = true;
        now = pt[i];
    }
}

signed main(){
    cin >> n >> m;
    init(n);
    rep(i, 0, m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }
    warshall_floyd();
    rep(i, 0, n) rep(j, 0, n) f[i][j] = false; 
    rep(i, 0, n){
        rep(j, i + 1, n){
            path(i, j);
        }
    }
    int ans = 0;
    rep(i, 0, m){
        if(f[a[i]][b[i]] == false && f[b[i]][a[i]] == false) ans++;
    }
    o(ans);
}