from heapq import heappop, heappush

n, m = map(int, input().split())
links = [set() for _ in range(n)]
link_list = []
for _ in range(m):
    s, t, c = map(int, input().split())
    s, t = s - 1, t - 1
    link_list.append((s, t, c))
    links[s].add((c, t))
    links[t].add((c, s))

result = 0
for s, t, limit in link_list:
    queue = [(0, s)]
    visited = set()
    while queue:
        c, v = heappop(queue)
        if v == t:
            result += 1
            break
        if c >= limit:
            break
        if v in visited:
            continue
        visited.add(v)
        for nc, nv in links[v]:
            if nv in visited:
                continue
            if v == s and nv == t:
                continue
            heappush(queue, (c + nc, nv))
print(result)
