n,m=map(int,input().split())
abc=[list(map(int,input().split())) for _ in range(m)]
d=[[1<<32 for _ in range(n)] for _ in range(n)]
for a,b,c in abc:
    d[a-1][b-1]=c
    d[b-1][a-1]=c
for i in range(n):
    d[i][i]=0
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for a,b,c in abc:
    j=True
    for s in range(n):
        if d[s][a-1]+c==d[s][b-1]:
            j=False
    if j: ans+=1
print(ans)