import heapq

N, M = map(int, input().split())
graph = {i:[] for i in range(1, N+1)}
v = set()
route = {}

for i in range(M):
    a, b, c = map(int, input().split())
    graph[a].append((c, b))
    graph[b].append((c, a))
    v.add(a)
    v.add(b)
    if a > b:
        route[(a,b)] = False
    else:
        route[(b,a)] = False
        
while v:
    visited = [False for i in range(N+1)]
    q = []
    s = v.pop()
    for c, r in graph[s]:
        heapq.heappush(q, (c, r, s))
        
    visited[1] = True    
    while q:
        c, r, s = heapq.heappop(q)    
        if not visited[r]:
            visited[r] = True
            
            if r in v:
                v.remove(r)
            if r > s:
                route[(r,s)] = True
            else:
                route[(s,r)] = True
            
            for c_, r_ in graph[r]:
                if not visited[r_]:
                    heapq.heappush(q, (c+c_, r_, r))
ans = 0
for i in route.values():
    if not i:
        ans += 1
print(ans)