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
  dist[a][a] = 0
  dist[b][b] = 0

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):
  s = min(dist[a][x]+dist[x][b] if x!=a and x!=b else 10**10 for x in range(1,N+1))
  if s==dist[a][b]:
    ans += 1
print(ans)