N, M = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(M)]
wf = [[[2000 for _ in range(N + 10)] for _ in range(N + 10)] for _ in range(N + 10)]
for i in range(N):
    for j in range(N):
        wf[i][j][j] = 0
for item in edge:
    a, b, c = item
    wf[0][a][b] = c
    wf[0][b][a] = c

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

ans = 0
for item in edge:
    a, b, c = item
    if c > wf[N][a - 1][b - 1]:
        ans += 1

print(ans)