N, M = [int(_) for _ in input().split()]
ABC = sorted([[int(_) for _ in input().split()]
              for _ in range(M)], key=lambda x: x[2])
G = [[10000] * N for _ in range(N)]
ans = 0
for a, b, c in ABC:
    a -= 1
    b -= 1
    m = min(G[a][i] + G[b][i] for i in range(N))
    if m < c:
        ans += 1
    else:
        m = c
    G[a][b], G[b][a] = m, m
print(ans)
