import heapq
from collections import defaultdict

N, M = map(int, raw_input().split())
X = [map(int, raw_input().split()) for _ in range(M)]

E = defaultdict(list)
for a, b, c in X:
    E[a].append((b, c))
    E[b].append((b, c))

def dijkstra(E, s):
    visited = set()
    prev = {}
    hq = []
    heapq.heappush(hq, (0, s, -1))
    while hq:
        cost, a, p = heapq.heappop(hq)
        visited.add(a)
        prev[a] = p
        for b, c in E[a]:
            if b in visited:
                continue
            heapq.heappush(hq, (cost + c, b, a))
    return prev

minpath = set()
for s in range(1, N+1):
    prev = dijkstra(E, s)
    for k in prev:
        if prev[k] == -1:
            continue
        minpath.add((k, prev[k]))
        minpath.add((prev[k], k))
print M - len(minpath) / 2