import numpy as np
import itertools
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

N, M = map(int, input().split())
G = np.array([tuple(map(int, input().split())) for _ in range(M)])
G[:, 0:-1] -= 1

matr = csr_matrix((G[:, 2], (G[:, 0], G[:, 1])), shape=(N, N))
way = floyd_warshall(matr, directed=False).astype(int).tolist()

ans = M
for i, j, d in G:
    for s, t in itertools.combinations(range(N), 2):
        if way[s][i] + d + way[j][t] == way[s][t]:
            ans -= 1
            break
print(ans)
