from copy import deepcopy
N, M = map(int, input().split())
graph = [[10000 for _ in range(N)] for l in range(N)]

for i in range(M):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1

  graph[b][a] = c
  graph[a][b] = c

newGraph = deepcopy(graph)

for k in range(N):
  for i in range(N):
    for j in range(N):
      graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

res = 0
for (i, row) in enumerate(newGraph):
  for (j, weight) in row:
    if (graph[i][j] != weight):
      res += 1

print(res/2)