N, M = list(map(int, input().split()))

graph = [[float('inf')]*N for i in range(N)]

graph2 = [[float('inf')]*N for i in range(N)]

for i in range(M):

    a, b, c = list(map(int, input().split()))

    graph[a-1][b-1] = c

    graph[b-1][a-1] = c

    graph2[a-1][b-1] = c

    graph2[b-1][a-1] = c



edge = set()



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((M - len(edge)//2))
N, M = list(map(int, input().split()))

G = [[float('inf')]*N for i in range(N)]

G2 = [[float('inf')]*N for i in range(N)]

for i in range(M):

    a, b, c = list(map(int, input().split()))

    G[a-1][b-1] = c

    G[b-1][a-1] = c

    G2[a-1][b-1] = c

    G2[b-1][a-1] = c



for k in range(N):

    for i in range(N):

        for j in range(N):

            if G[i][j] > G[i][k] + G[k][j]:

                G[i][j] = G[i][k] + G[k][j]



not_change = set()

for i in range(N):

    for j in range(N):

        if G[i][j] == G2[i][j]:

            not_change.add((i, j))



print((M - len(not_change)//2))



N, M = list(map(int, input().split()))
graph = [[float("inf")] * N for i in range(N)]
graph2 = [[float("inf")] * N for i in range(N)]
for i in range(M):
    a, b, c = list(map(int, input().split()))
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
    graph2[a - 1][b - 1] = c
    graph2[b - 1][a - 1] = c
edge = set()
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((M - len(edge) // 2))

N, M = list(map(int, input().split()))
G = [[float("inf")] * N for i in range(N)]
G2 = [[float("inf")] * N for i in range(N)]
for i in range(M):
    a, b, c = list(map(int, input().split()))
    G[a - 1][b - 1] = c
    G[b - 1][a - 1] = c
    G2[a - 1][b - 1] = c
    G2[b - 1][a - 1] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            if G[i][j] > G[i][k] + G[k][j]:
                G[i][j] = G[i][k] + G[k][j]
not_change = set()
for i in range(N):
    for j in range(N):
        if G[i][j] == G2[i][j]:
            not_change.add((i, j))
print((M - len(not_change) // 2))

-graph = [[float("inf")] * N for i in range(N)] -graph2 = [[float("inf")] * N for i in range(N)] +G = [[float("inf")] * N for i in range(N)] +G2 = [[float("inf")] * N for i in range(N)] -    graph[a - 1][b - 1] = c -    graph[b - 1][a - 1] = c -    graph2[a - 1][b - 1] = c -    graph2[b - 1][a - 1] = c -edge = set() +    G[a - 1][b - 1] = c +    G[b - 1][a - 1] = c +    G2[a - 1][b - 1] = c +    G2[b - 1][a - 1] = c -            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((M - len(edge) // 2)) +            if G[i][j] > G[i][k] + G[k][j]: +                G[i][j] = G[i][k] + G[k][j] +not_change = set() +for i in range(N): +    for j in range(N): +        if G[i][j] == G2[i][j]: +            not_change.add((i, j)) +print((M - len(not_change) // 2))