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