N,M = list(map(int,input().split()))
abc = []
abc = [list(map(int,input().split())) for i in range(M)]

A=[]
B=[]
C=[]
dist=[[1000]*N for i in range(N)]

for i in range(M):
    A.append(abc[i][0])
    B.append(abc[i][1])
    C.append(abc[i][2])
    
for i in range(N):
    dist[A[i]-1][B[i]-1] = C[i]
    dist[B[i]-1][A[i]-1] = C[i]

for i in range(N):
    for j in range(N):
        for k in range(N):
            dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])
            
count = 0
for i in range(N):
    if dist[abc[i][0]-1][abc[i][1]-1] != abc[i][2]:
        count+=1
        
print(count)