n,m=map(int,raw_input().split())
a=[0]*m;b=[0]*m;c=[0]*m
p=[[10e9 for i in range(n)] for i in range(n)]
for i in range(n):p[i][i]=0
for i in range(m):
    a[i],b[i],c[i]=map(int,raw_input().split())
    a[i]-=1;b[i]-=1
    p[a[i]][b[i]]=p[b[i]][a[i]]=c[i]
for i in range(n):
    for j in range(n):
        for k in range(n):
            p[j][k]=min(p[j][k],p[j][i]+p[i][k])
            p[k][j]=p[j][k]
cnt=0
for i in range(m):
    if p[a[i]][b[i]]<c[i]:cnt+=1
print cnt
