#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> tp;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int main(){
    int N,M;
    cin >> N >> M;
    vector<tp> V(M);
    int dist[N][N];
    rep(i,0,N)rep(j,0,N)dist[i][j] = INF;
    rep(i,0,N)dist[i][i] = 0;
    rep(i,0,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        V[i] = make_tuple(a,b,c);
        dist[a][b] = dist[b][a] = c;
    }
    rep(i,0,N)rep(j,0,N)rep(k,0,N)dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
    int cnt = 0;
    rep(i,0,M){
        int a = get<0>(V[i]), b = get<1>(V[i]), c = get<2>(V[i]);
        if(dist[a][b] != c)cnt++;
    }
    cout << cnt << endl;
}