N,M = map(int,input().split())
abc= [list(map(int,input().split())) for _ in [0]*M]
d = [[10000*N]*N for _ in [0]*N]
for a,b,c in abc:
    d[a-1][b-1]=c
    d[b-1][a-1]=c
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=sum(d[a-1][b-1]<c for a,b,c in abc)
print(ans)