#include <iostream>
#include <cstdio>
#define N 105
#define M 1005
using namespace std;

int n, m, ans, a[M], b[M], c[M], d[N][N];
int main()
{
	int i, j, k;
	cin >> n >> m;
	for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) if (i != j) d[i][j] = 1e9;
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
		d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
	}
	for (k = 1; k <= n; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	for (i = 0; i < m; i++) if (d[a[i]][b[i]] < c[i]) ans++;
    cout << ans << endl;
    return 0;
}