from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

graph = [[0] * n for _ in range(n)]
for a, b, c in abc:
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c

dist, pre = floyd_warshall(csr_matrix(graph), return_predecessors=True)

edges = set()
for s in range(n):
    for g in range(s + 1, n):
        while g != s:
            par_g = pre[s][g]
            edge = sorted([par_g, g])
            edge = tuple(edge)
            edges.add(edge)
            g = par_g

ans = m - len(edges)
print(ans)
