#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using pii = pair<int, int>;
#define int ll
#define INF 1e18
using ll = long long;
signed main(){
    int n,m; cin>>n>>m;
    vector<vector<int>>d(n,vector<int>(n,INF));
    rep(i,m){
        int a,b,c; cin>>a>>b>>c;
        d[a-1][b-1]=d[b-1][a-1]=c;
    }
    vector<vector<int>>d_min;
    rep(i,n)d[i][i]=0;
    d_min=d;
    rep(k,n)rep(i,n)rep(j,n)d_min[i][j]=min(d_min[i][j],d_min[i][k]+d_min[k][j]);
    int ans=0;
    rep(i,n)rep(j,n)if(i!=j&&d[i][j]!=INF&&d_min[i][j]!=INF&&d[i][j]!=d_min[i][j])
        ans++;
    cout<<ans/2<<endl;
    return 0;
}
