n,m=map(int,input().split())
edge=[]
branch=[[] for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a-1,b-1,c))
    branch[a-1].append((b-1,c))
    branch[b-1].append((a-1,c))

dist=[]
def makedist(start,branch):
    check={start,}
    mind=[10**7 for i in range(n)]
    mind[start]=0
    while len(check)>0:
        now=check.pop()
        for k in branch[now]:
            if k[1]+mind[now]<mind[k[0]]:
                mind[k[0]]=k[1]+mind[now]
                check|={k[0],}
    return mind
for i in range(n):
    dist.append(makedist(i,branch))
ans=0
for k in edge:
    for s in range(n):
        if s==k[0] or s==k[1]:continue
        elif abs(dist[s][k[0]]-dist[s][k[1]])==k[2]:
            ans+=1
            break
print(m-ans)