n,m=[int(x) for x in input().split()]
path=[]
d=[[float("inf") for _ in [0]*n] for _2 in [0]*n]
for _ in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    path.append((a-1,b-1,c))
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import product
for k,i,j in product(range(n),range(n),range(n)):
    if d[i][j]>d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
ans=0
for a,b,c in path:
    if d[a][b]!=c:
        ans+=1
print(ans)