
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;


int main() {
	int N, M, a[1000], b[1000], c[1000];
	int dist[100][100];
	int i,j,k,ans;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			dist[i][j] = 9999999;
		}
		dist[i][i] = 0;
	}
	for (i = 0; i < M; i++) {
		dist[a[i] - 1][b[i] - 1] = c[i];
		dist[b[i] - 1][a[i] - 1] = c[i];
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			for (k = 0; k < N; k++) {
				if (dist[j][k] > dist[j][i] + dist[i][k]) {
					dist[j][k] = dist[j][i] + dist[i][k];
				}
			}
		}
	}

	ans = 0;
	for (i = 0; i < M; i++) {
		if (dist[a[i] - 1][b[i] - 1] < c[i]) { ans++; }
	}

	printf("%d", ans);
}
