#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll e[1005][1005];
ll d[1005][1005];
ll n,m;
ll a[1005],b[1005],c;
ll ans;
int main(void){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j){
				d[i][j]=0;
			}else{
				d[i][j]=100000000;
			}
		}
	}
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i]>>c;
		e[a[i]-1][b[i]-1]=c; e[b[i]-1][a[i]-1]=c;
		d[a[i]-1][b[i]-1]=c; d[b[i]-1][a[i]-1]=c;
	}
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(int i=0;i<m;i++){
		if(d[a[i]-1][b[i]-1]<e[a[i]-1][b[i]-1]){
			ans++;
		}
	}
	cout<<ans<<endl;
	
}
