from scipy.sparse.csgraph import dijkstra

INF = 10 ** 18
N, M = map(int, input().split())
d = [[INF for _ in range(N)] for _ in range(N)]
abc = []

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

dtra = dijkstra(d)
minlst = [INF] * N
for i in range(N):
    for j in range(N):
        if dtra[i][j] != 0:
            minlst[i] = min(minlst[i], dtra[i][j])

cnt = 0
for i in range(M):
    if int(minlst[abc[i][1]]) < abc[i][2]:
        cnt += 1

print(cnt)