N,M=map(int,input().split())
from collections import defaultdict
B=[tuple(map(int,input().split())) for i in range(M)]
dist=defaultdict(lambda : float('inf'))
for i,x in enumerate(B):
    a,b,c=x[0]-1,x[1]-1,x[2]
    dist[(a,b)]=c
    dist[(b,a)]=c
for i in range(N):
    dist[(i,i)]=0
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[(i,j)]=min(dist[(i,j)],dist[(i,k)]+dist[(j,k)])
            dist[(j,i)]=dist[(i,j)]
cnt=0
for x in B:
    a,b,c=x[0]-1,x[1]-1,x[2]
    if dist[(a,b)]!=c:
        cnt+=1
print(cnt)