#include <iostream>
#include <cstdio>
using namespace std;

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