#include<cstdio>
const static int INF = 1000000;

int main(){
	int N, M;
	scanf("%d %d", &N, &M);
	int d[N][N];
	for (int i = 0; i < N; ++i){
		for (int j = 0; j < N; ++j) d[i][j] = INF;
	}
	int a[M], b[M], c[M];
	for (int i = 0; i < M; ++i){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--, b[i]--;
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}
	for (int k = 0; k < N; ++k){
		for (int i = 0; i < N; ++i){
			for (int j = 0; j < N; ++j) if(d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
		}
	}
	int answer = 0;
	for (int i = 0; i < M; ++i) if(c[i] > d[a[i]][b[i]]) answer++;
	printf("%d\n", answer);
	return 0;
}