#include <cstdio>
#define INF 10000000;
using namespace std;
int n,m;
long long dp[100][100];
int a[1000],b[1000],c[1000];

void initialize(void){
	for(int lp1=0;lp1<100;lp1++){
		for(int lp2=0;lp2<100;lp2++){
			if(lp1==lp2){
				dp[lp1][lp2]=0;
			}else{
				dp[lp1][lp2]=INF;
			}
		}
	}
}

void input(void){
	int edge_a,edge_b,edge_c;
	scanf("%d %d",&n,&m);
	for(int lp1=0;lp1<m;lp1++){
		scanf("%d %d %d",&edge_a,&edge_b,&edge_c);
		a[lp1]=edge_a;
		b[lp1]=edge_b;
		c[lp1]=edge_c;
		dp[edge_a-1][edge_b-1]=edge_c;
		dp[edge_b-1][edge_a-1]=edge_c;
	}
}

void shortestpath(void){
	for(int lp1=0;lp1<n;lp1++){
		for(int lp2=0;lp2<n;lp2++){
			for(int lp3=0;lp3<n;lp3++){
				dp[lp2][lp3]=std:min(dp[lp2][lp3],dp[lp2][lp1]+dp[lp1][lp3]);
			}
		}
	}
} 

void pathprint(void){
	printf("pathprint called\n");
	for(int lp1=0;lp1<n;lp1++){
		for(int lp2=0;lp2<n;lp2++){
			printf("%d to %d is %d\n",lp1,lp2,dp[lp1][lp2]);
		}
	}
}

int solve(void){
	bool shortest=false;
	int answer=0;
	for(int lp1=0;lp1<m;lp1++){
		if(c[lp1]>dp[a[lp1]-1][b[lp1]-1]) answer++;
	}
	return answer;
}

int main(void){
	initialize();
	input();
	//pathprint();
	shortestpath();
	//printf("going to call pathprint2\n");
	//pathprint();
	printf("%d\n",solve());
	return 0;
}
	
