from copy import deepcopy

N,M = map(int,input().split())
l = [[float('inf') for _ in range(N)] for _ in range(N)]
X = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
  l[X[i][0]-1][X[i][1]-1] = X[i][2]
  l[X[i][1]-1][X[i][0]-1] = X[i][2]
for i in range(N):
  l[i][i] = 0
d = deepcopy(l)
for i in range(N):
  for j in range(i):
    m = min(a+b for a,b in zip(d[i], d[j]))
    d[i][j] = m
    d[j][i] = m

count = 0
for i in range(N):
  for j in range(i):
    if l[i][j] != d[i][j] and l[i][j]!=float('inf'):
      count += 1

print(count)
