N, M = map(int, input().split())
G = [[10000 for j in range(N)] for i in range(N)]
E = [(0, 0, 0)] * M
for i in range(N):
  G[i][i] = 0
for i in range(M):
  a, b, c = map(int, input().split())
  E[i] = (a - 1, b - 1, c)
  G[a - 1][b - 1] = c
  G[b - 1][a - 1] = c
def warshall_floyd(G):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        G[i][j] = min(G[i][k] + G[k][j], G[i][j])
  return G
G = warshall_floyd(G)
cnt = 0
for e in E:
  for s in range(N):
    if G[s][e[1]] == G[s][e[0]] + e[2]:
      break
  else:
    cnt += 1
print(cnt)