n,m=map(int,input().split())
d=[[float('inf') for i in range(n)] for i in range(n)]
r=[list(map(int,input().split())) for i in range(m)]

def wf(d):
    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])
    return d


for u,v,c in r:
    u,v=u-1,v-1
    d[u][v]=d[v][u]=c

wf(d)

cnt=0
for u,v,c in r:
    u,v=u-1,v-1
    if d[u][v]!=c:
        cnt+=1
print(cnt)