N,M = map(int, raw_input().split())
EDGES = [[0 for j in range(N)] for i in range(N)]
for i in range(M):
  a,b,c = map(int, raw_input().split())
  EDGES[a-1][b-1] = c
  EDGES[b-1][a-1] = c
notused = 0
for i in range(N):
  for j in range(i):
    edge = EDGES[i][j]
    for k in range(N):
      if(k == i or k == j):
        continue
      if edge > EDGES[i][k] + EDGES[k][j]:
        notused += 1
print notused