import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

ABC.sort(key=lambda x:x[2])
INF = 1 << 28
ds = [[INF] * N for _ in range(N)]
for i in range(N):
    ds[i][i] = 0

cnt = 0
for abc in ABC:
    a, b, c = abc
    a -= 1
    b -= 1
    if ds[a][b] <= c:
        cnt += 1
        continue

    ds[a][b] = ds[b][a] = c

    for i in range(N):
        for j in range(N):
            if ds[i][j] > ds[i][a] + ds[a][b] + ds[b][j]:
                ds[i][j] = ds[j][i] = ds[i][a] + ds[a][b] + ds[b][j]

print(cnt)
