N, M = map(int, input().split())
inf = 10**6
abc = []
d = [[inf]*N for i in range(N)]
for i in range(M):
	a, b, c = map(int, input().split())
	d[a-1][b-1] = c
	d[b-1][a-1] = c
	abc.append((a-1,b-1,c))

for k in range(N):
	for i in range(N):
		for j in range(N):
			d[i][j] = min(d[i][k]+d[k][j], d[i][j])
ans = 0
for i in range(M):
	a, b, c = abc[i]
	if d[a][b] < inf and d[a][b] < c:
		ans += 1
print(ans)