import heapq

n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    g[a].append((b,c))
    g[b].append((a,c))

used=set()

for i in range(n):
    visit=[0]*n
    q=[(0,i,-1)]
    dist=[0]*n

    while len(q)>0:
        d,u,v=heapq.heappop(q)

        if visit[u]==1:
            continue

        if v>=0:
            used.add((max(u,v),min(u,v)))

        visit[u]=1
        dist[u]=d

        for w,nd in g[u]:
            if visit[w]==1:
                continue

            heapq.heappush(q,(dist[u]+nd,w,u))

print(m-len(used))
