N, M = map(int, input().split())
graph = [[float('inf')]*N for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = a

edge = set()
graph2 = graph.copy()
for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph2[i][k] + graph2[k][j] < graph2[i][j]:
                graph2[i][j] = min(graph2[i][j], graph2[i][k] + graph2[k][j])

for k in range(N):
    for i in range(N):
        for j in range(N):
            if graph[i][j] == graph2[i][j]:
                edge.add(tuple([i, j]))


print(int(M - ((len(edge)-N) / N)))