n,m=map(int,input().split())
from collections import defaultdict
dist=defaultdict(int)
branch=[]
for k in range(m):
    branch.append(tuple(map(int,input().split())))
branch.sort(key=lambda x:x[2],reverse=True)
ans=0
for k in range(m):
    check=branch.pop()
    a,b,c=check[0],check[1],check[2]
    if dist[(a,b)]==0:
        dist[(a,b)]=c
        dist[(b,a)]=c
        for i in range(1,1+n):
            if i==a or i==b:continue
            if dist[(a,i)]!=0 and dist[(b,i)]==0:
                dist[(b,i)]=c+dist[(a,i)]
                dist[(i,b)]=c+dist[(a,i)]
            if dist[(b,i)]!=0 and dist[(a,i)]==0:
                dist[(a,i)]=c+dist[(b,i)]
                dist[(i,a)]=c+dist[(b,i)]
    elif dist[(a,b)]<c:
        ans+=1
    elif dist[(a,b)]>c:
        dist[(a,b)]=c
        dist[(b,a)]=c
        for i in range(1,1+n):
            if i==a or i==b:continue
            if dist[(a,i)]!=0 and dist[(b,i)]==0:
                dist[(b,i)]=c+dist[(a,i)]
                dist[(i,b)]=c+dist[(a,i)]
            if dist[(b,i)]!=0 and dist[(a,i)]==0:
                dist[(a,i)]=c+dist[(b,i)]
                dist[(i,a)]=c+dist[(b,i)]
            if dist[(a,i)]!=0 and dist[(a,i)]!=0:
                if dist[(a,i)]+c<dist[(b,i)]:
                    dist[(b,i)]=dist[(a,i)]+c
                    dist[(i,b)]=dist[(a,i)]+c
                if dist[(b,i)]+c<dist[(a,i)]:
                    dist[(a,i)]=c+dist[(b,i)]
                    dist[(i,a)]=c+dist[(b,i)]
print(ans)