N, M, *L = map(int, open(0).read().split())
dist = [[10**10]*(N+1) for i in range(N+1)]
for a,b,c in zip(*[iter(L)]*3):
  dist[a][b] = c
  dist[b][a] = c

for k in range(1,N+1):
  for p in range(1,N+1):
    for q in range(1,N+1):
      dist[p][q] = min(dist[p][q],dist[p][k]+dist[k][q])

ans = 0
for a,b,c in zip(*[iter(L)]*3):
  if c>dist[a][b]:
    ans += 1
    continue
  s = min(x+y for x,y in zip(dist[a],dist[b]))
  if s==c:
    ans += 1
print(ans)