N, M = map(int, input().split())
Adj = [[10 ** 7 for j in range(N)] for i in range(N)]
for i in range(N):
  Adj[i][i] = 0
Edge = []
for m in range(M):
  a, b, c = map(int, input().split())
  Adj[a - 1][b - 1] = c
  Adj[b - 1][a - 1] = c
  Edge.append([a - 1, b - 1, c])
for i in range(N):
  for j in range(N):
    for k in range(N):
      Adj[i][j] = min(Adj[i][k] + Adj[k][j], Adj[i][j])
Used = [1 for m in range(M)]
for i, e in enumerate(Edge):
  for s in range(N):
    if Adj[s][e[0]] + e[2] == Adj[s][e[1]]:
      Used[i] = 0
print(sum(Used))