from heapq import heappush, heappop
n, m = map(int, raw_input().split())
G = [[] for i in xrange(n)]
E = {}
for i in xrange(m):
    a, b, c = map(int, raw_input().split())
    G[a-1].append((b-1, c))
    G[b-1].append((a-1, c))
    E[a-1, b-1] = E[b-1, a-1] = [c, 0]
def dijkstra(s):
    dist = [10**18]*n
    prev = [-1]*n
    que = [(0, s)]
    dist[s] = 0
    dic = set()
    while que:
        co, v = heappop(que)
        if dist[v] < co:
            continue
        for t, cost in G[v]:
            if co + cost < dist[t]:
                dist[t] = co + cost
                heappush(que, (co+cost, t))
                prev[t] = v
    for i in xrange(n):
        if prev[i] != -1:
            dic.add((i, prev[i]))
    return dic

ans = m
for i in xrange(n):
    dic = dijkstra(i)
    for k in dic:
        e = E[k]
        if e[1] == 0:
            ans -= 1
            e[1] = 1
print ans