n, m = map(int, input().split())
cs = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    cs[i][i] = 0
es = []
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    es.append((a, b, c))
    cs[a][b] = cs[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j])
print(sum([1 for a, b, c in es if cs[a][b] != c]))