#include<iostream>
#define INF 1e6
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m,a,b,c;
	cin>>n>>m;
	int edge[n][n];
	int dist[n][n];
	rep(i,n)rep(j,n)dist[i][j]=edge[i][j]=INF;
	rep(i,m){
		cin>>a>>b>>c;
		a--;b--;
		edge[a][b]=edge[b][a]=dist[a][b]=dist[b][a]=c;
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int ans=0;
	int flg[n][n];
	rep(i,n)fill(flg[i],flg[i]+n,true);
	rep(i,n){
		rep(j,n){
			if(i==j)continue;
			if(edge[i][j]!=dist[i][j]&&flg[i][j]&&edge[i][j]!=INF){
				ans++;
				flg[i][j]=flg[j][i]=false;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}