MAX = 9999
N, M = map(int, input().split())

cost = []
dist = [[MAX] * N for i in range(N)]
for i in range(N):
	dist[i][i] = 0

#print(dist)

for i in range(M):
	cost.append(list(map(int, input().split())))

#print(cost)

for a, b, c in cost:
	dist[a-1][b-1] = c
	dist[b-1][a-1] = c

print(dist)

for k in range(N):
	for i in range(N):
		for j in range(N):
			dist[i][j] = min(dist[i][j], dist[i][k] + dis[k][j])

ans = 0
for a, b, c in cost:
	if dist[a-1][b-1] < c:
		ans += 1
		
print(ans)