N, M = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(M)]

inf = 1000000
L = [[0] * N for _ in range(N)]
C = [[inf] * N for _ in range(N)]
for i in range(M):
  a, b, c = abc[i]
  a -= 1
  b -= 1
  C[a][b] = c
  C[b][a] = c

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

for k in range(N):
  for i in range(N):
    for j in range(N):
      if C[i][j] > C[i][k] + C[k][j]:
        C[i][j] = C[i][k] + C[k][j]
        L[i][j] = 1

n = 0
for i in range(N):
  for j in range(N):
    if L[i][j] == 1:
      n += 1

print(M - ((N * (N - 1) // 2) - (n // 2)))
