N,M = (int(x) for x in input().split())
a= [0]*1000
b = [0]*1000
c = [0]*1000
dist= [[0]*100 for i in range(100)]
for i in range(M):
    a[i],b[i],c[i] = (int(x) for x in input().split())
for i in range(N):
    for j in range(N):
        if(i==j):
            dist[i][j] = 0
        else:dist[i][j] = float('inf')

for i in range(M):
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]],c[i])
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]],c[i])

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
ans = M
for i in range(M):
    flag = 0
    for j in range(N):
        if(dist[j][a[i]]+c[i] == dist[j][b[i]]):
            flag = 1
            if(flag == 1):
                ans -= 1
print(ans)