#coding:utf-8

N,M=map(int,raw_input().split())
D=[[1145141919]*101 for _ in range(101)]
R=[[1145141919]*101 for _ in range(101)]

A=set()
for i in range(M):
    a,b,c=map(int,raw_input().split())
    D[a][b]=c;D[b][a]=c
    R[a][b]=c;R[b][a]=c
    A.add((min(a,b),max(a,b)))

for i in range(1,N+1):D[i][i]=0


for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            if D[i][j]>D[i][k]+D[k][j]:
                D[i][j]=D[i][k]+D[k][j]    
ans=0
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if R[i][j]==1145141919:continue
        if D[i][j]!=R[i][j]:ans+=1
print(ans)

