N,M=[int(i) for i in input().split()]
edges=[[2**60 for i in range(N)] for j in range(N)]
for i in range(M):
    a,b,c=[int(i) for i in input().split()]
    a-=1
    b-=1
    edges[a][b]=edges[b][a]=c

mini=[[edges[i][j] for i in range(N)] for j in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            mini[i][j]=min(mini[i][j],mini[i][k]+mini[k][j])
res=0
for r in range(N):
    for l in range(r):
        #print(l,".",r,"->",edges[l][r],mini[l][r])
        if edges[l][r] != 2**60 and mini[l][r]<edges[l][r]:
            res+=1
print(res)
