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):
        if i != j and i != path[i][j]:
            used.add((i, path[i][j]))
            
print(M - len(used))
