#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>

int f[110][110], d[110][110];
#define cmin(a, b) (a > (b) ? a = (b) : 0)
int main()
{
	int n, m; scanf("%d%d", &n, &m);
	memset(d, 63, sizeof (d));
	for (int i = 1; i <= m; ++i)
	{
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		d[a][b] = d[b][a] = f[a][b] = f[b][a] = c;
	}
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				cmin(d[i][j], d[i][k] + d[k][j]);
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if (f[i][j] && d[i][j] < f[i][j])
				++ans;
	printf("%d\n", ans >> 1);
	return 0;
}