#include <iostream>
#include <cstdio>
int n, m, s, a[105][105], b[105][105];
int main() {
	int i, j, k, x, y, z;
	scanf("%d%d", &n, &m);
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) b[i][j] = 1e9;
	while(m--) {
		scanf("%d%d%d", &x, &y, &z);
		a[x][y] = a[y][x] = b[x][y] = b[y][x] = z;
	}
	for(k=1; k<=n; k++) for(i=1; i<=n; i++) for(j=1; j<=n; j++)
		b[i][j] = std::min(b[i][j], b[i][k] + b[k][j]);
	for(i=1; i<=n; i++) for(j=i+1; j<=n; j++)
		s += (a[i][j] > b[i][j]);
	printf("%d", s);
	return 0;
}