#include<cstdio>
#include<algorithm>
using namespace std;

const int INF = 1000000000;

int main(){
	int n,m;
	int dist[100][100];
	int ans = 0;
	int a[1000],b[1000],c[1000];
	scanf("%d %d",&n,&m);
	fill(dist[0],dist[0]+10000,INF);
	for(int i=0;i<m;i++){
		scanf("%d %d %d",a+i,b+i,c+i);
		a[i]--;
		b[i]--;
		dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
	}
	for(int i=0;i<n;i++) dist[i][i] = 0;
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(dist[i][k]!=INF&&dist[k][j]!=INF) dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	for(int i=0;i<m;i++){
		bool flag = true;
		for(int s=0;s<n;s++){
			if(dist[s][a[i]]+c[i]==dist[s][b[i]]) flag = false;
		}
		if(flag) ans++;
	}
	printf("%d\n",ans);
}
