n, m = map(int, input().split())
d = [[float("inf") for _ in range(n)] for _ in range(n)]
d_org = [[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
	d_org[a - 1][b - 1] = c
	d_org[b - 1][a - 1] = c

for i in range(n):
	for j in range(n):
		if i == j:
			continue
		for k in range(n):
			if d[i][k] + d[k][j] < d[i][j]:
				d[i][j] = d[i][k] + d[k][j]

ans = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		if d_org[i][j] < float("inf") and d_org[i][j] > d[i][j]:
			ans += 1

print(ans)