import heapq
n,m=map(int,input().split())
g=[[] for i in range(n)]
p=[]
for i in range(m):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    p.append([a,b,c])
    g[a].append([c,b])
    g[b].append([c,a])
ans=0
for i in range(m):
    s=p[i][0]
    goal=p[i][1]
    c=p[i][2]
    q=[]
    heapq.heappush(q,[0,s])
    v=[-1]*n
    v[s]=0
    while q:
        p=heapq.heappop(q)
        if p[1]==goal:
            break
        for i in g[p[1]]:
            if v[i[1]]==-1:
                v[i[1]]=i[0]+v[p[1]]
                heapq.heappush(q,[v[i[1]],i[1]])
    if p[0]<c:
        ans+=1
print(ans)