n, m = map(int, input().split())
d = [[float("inf") for _ in range(n)] for _ in range(n)]
for _ in range(m):
	a, b, c = map(int, input().split())
	d[a - 1][b - 1] = c
	d[b - 1][a - 1] = c

ans = 0

for i in range(n):
	for j in range(i + 1, n):
		if d[i][j] == float("inf"):
			continue
		for k in range(n):
			if d[i][k] + d[k][j] < d[i][j]:
				ans += 1
				break

print(ans)