import sys
sys.setrecursionlimit(10000)

n, m = map(int, input().split())
abc = [tuple(int(x) - 1 for x in input().split()) for _ in range(m)]

dist = [[9999999 for _ in range(n)] for _ in range(n)]

e = [dict() for _ in range(n)]

for i in range(m):
    a, b, c = abc[i][0], abc[i][1], abc[i][2]
    e[a][b] = c + 1
    e[b][a] = c + 1

for i in range(n):
    dist[i][i] = 0
    temp = set()
    temp.add(i)
    while len(temp) < n:
        next = -1
        nc = 99999999
        for x in temp:
            for y in e[x].keys():
                if y in temp:
                    continue
                if dist[i][x] + e[x][y] < nc:
                    nc = dist[i][x] + e[x][y]
                    next = y
        temp.add(next)
        dist[i][next] = nc

ans = m
for a, b, c in abc:
    for i in range(n):
        if c + 1 == dist[a][i] - dist[b][i]:
            ans -= 1
            break
print(ans)