N, M = map(int, input().split())
ABC = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 10
dist = [[INF for _ in range(N + 1)] for _ in range(N + 1)]

for a, b, c in ABC:
  dist[a][b] = c
  dist[b][a] = c

for k in range(1, N + 1):
  for i in range(1, N + 1):
    for j in range(1, N + 1):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
#print("dist:", dist)

check = [0] * (M)
for i in range(M):
  a, b, c = ABC[i]
  for j in range(1, N + 1):
    if dist[j][b] == dist[j][a] + c:
      check[i] = 1
      break
print(len(check) - sum(check))