from heapq import heappush, heappop
from collections import defaultdict, deque
n, m = map(int, input().split())
G = defaultdict(list)
E = []
for i in range(m):
    a, b, c = map(int, input().split())
    G[a - 1].append((b - 1, c))
    G[b - 1].append((a - 1, c))
    E.append((a - 1, b - 1, c))

INF = float("inf")
d = [INF] * n
d[0] = 0
que = [(0, 0)]
while que:
    cost, v = heappop(que)
    if d[v] < cost:
        continue
    for w, c in G[v]:
        if cost + c < d[w]:
            d[w] = cost + c
            heappush(que, (cost + c, w))

num = m
for x, y, c in E:
    if d[x] +  c == d[y]:
        num -= 1

print(num)