from scipy.sparse.csgraph import dijkstra

N, M = map(int, input().split())
G = [[float('inf')]*N for i in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    G[a-1][b-1] = c
    G[b-1][a-1] = c

distance, path = dijkstra(G, directed=False, return_predecessors=True)

used = set()
for i in range(N):
    for j in range(N):
        t = j
        while i != t:
            t = path[i][t]
            if path[i][t] != t:
                used.add((path[i][t], t))

K = len(used)
for l, r in used:
    if l < 0 or r < 0:
        K -= 1
print(M - K)
