N, M = map(int, input().strip().split())
INF = 100000000

d = [[INF for _ in range(N)] for _ in range(N)]
abc = []

for _ in range(M):
  a, b, c = map(int, input().strip().split())
  d[a-1][b-1] = c
  d[b-1][a-1] = c
  abc.append((a-1, b-1, c))

for i in range(N):
  d[i][i] = 0

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

ans = M
for a, b, c in abc:
  shortest = False
  for j in range(N):
    if d[j][a]+c == d[j][b]:
      shortest = True
  if shortest:
    ans -= 1
print(ans)
