n, m = map(int, input().split())
inf = 10000000000
mat = [[inf if j!=i else 0 for j in range(i+1)] for i in range(n)]
abcs = [list(map(int, input().split())) for _ in range(m)]
for a, b, c in abcs:
    i, j = max(a, b)-1, min(a, b)-1
    mat[i][j] = min(mat[i][j], c)

for i in range(n):
    for j in range(n):
        for k in range(j):
            mat[j][k] = min(mat[j][k], mat[max(i, j)][min(i, j)]+mat[max(i, k)][min(i, k)])

print(sum(1 for a, b, c in abcs if c > mat[max(a, b)-1][min(a, b)-1]))