N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
INF = float('inf')
wf = [[INF]*N for i in range(N)]
for a,b,c in src:
    a,b = a-1,b-1
    wf[a][b] = wf[b][a] = c
for i in range(N):
    wf[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j])

ans = 0
for a,b,c in src:
    a,b = a-1,b-1
    if c != wf[a][b]:
        ans += 1
print(ans)