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

Adj = [[10 ** 7 for j in range(N)] for i in range(N)]

for i in range(N):

  Adj[i][i] = 0

Edge = []

for m in range(M):

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

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

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

  Edge.append([a - 1, b - 1, c])

for i in range(N):

  for j in range(N):

    for k in range(N):

      Adj[j][k] = min(Adj[j][i] + Adj[i][k], Adj[j][k])

Unused = [1 for m in range(M)]

for i, e in enumerate(Edge):

  for s in range(N):

    if Adj[s][e[0]] + e[2] == Adj[s][e[1]]:

      Unused[i] = 0

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

G = [[10000 for j in range(N)] for i in range(N)]

E = [(0, 0, 0)] * M

for i in range(N):

  G[i][i] = 0

for i in range(M):

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

  E[i] = (a - 1, b - 1, c)

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

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

def warshall_floyd(G):

  for k in range(N):

    for i in range(N):

      for j in range(N):

        G[i][j] = min(G[i][k] + G[k][j], G[i][j])

  return G

G = warshall_floyd(G)

cnt = 0

for e in E:

  for s in range(N):

    if G[s][e[1]] == G[s][e[0]] + e[2]:

      break

  else:

    cnt += 1

print(cnt)
N, M = list(map(int, input().split()))
Adj = [[10**7 for j in range(N)] for i in range(N)]
for i in range(N):
    Adj[i][i] = 0
Edge = []
for m in range(M):
    a, b, c = list(map(int, input().split()))
    Adj[a - 1][b - 1] = c
    Adj[b - 1][a - 1] = c
    Edge.append([a - 1, b - 1, c])
for i in range(N):
    for j in range(N):
        for k in range(N):
            Adj[j][k] = min(Adj[j][i] + Adj[i][k], Adj[j][k])
Unused = [1 for m in range(M)]
for i, e in enumerate(Edge):
    for s in range(N):
        if Adj[s][e[0]] + e[2] == Adj[s][e[1]]:
            Unused[i] = 0
print((sum(Unused)))

N, M = list(map(int, input().split()))
G = [[10000 for j in range(N)] for i in range(N)]
E = [(0, 0, 0)] * M
for i in range(N):
    G[i][i] = 0
for i in range(M):
    a, b, c = list(map(int, input().split()))
    E[i] = (a - 1, b - 1, c)
    G[a - 1][b - 1] = c
    G[b - 1][a - 1] = c


def warshall_floyd(G):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                G[i][j] = min(G[i][k] + G[k][j], G[i][j])
    return G


G = warshall_floyd(G)
cnt = 0
for e in E:
    for s in range(N):
        if G[s][e[1]] == G[s][e[0]] + e[2]:
            break
    else:
        cnt += 1
print(cnt)

-Adj = [[10**7 for j in range(N)] for i in range(N)] +G = [[10000 for j in range(N)] for i in range(N)] +E = [(0, 0, 0)] * M -    Adj[i][i] = 0 -Edge = [] -for m in range(M): +    G[i][i] = 0 +for i in range(M): -    Adj[a - 1][b - 1] = c -    Adj[b - 1][a - 1] = c -    Edge.append([a - 1, b - 1, c]) -for i in range(N): -    for j in range(N): -        for k in range(N): -            Adj[j][k] = min(Adj[j][i] + Adj[i][k], Adj[j][k]) -Unused = [1 for m in range(M)] -for i, e in enumerate(Edge): +    E[i] = (a - 1, b - 1, c) +    G[a - 1][b - 1] = c +    G[b - 1][a - 1] = c + + +def warshall_floyd(G): +    for k in range(N): +        for i in range(N): +            for j in range(N): +                G[i][j] = min(G[i][k] + G[k][j], G[i][j]) +    return G + + +G = warshall_floyd(G) +cnt = 0 +for e in E: -        if Adj[s][e[0]] + e[2] == Adj[s][e[1]]: -            Unused[i] = 0 -print((sum(Unused))) +        if G[s][e[1]] == G[s][e[0]] + e[2]: +            break +    else: +        cnt += 1 +print(cnt)