n, m = list(map(int, input().split()))

cs = [[float('inf')] * n for _ in range(n)]

for i in range(n):

    cs[i][i] = 0

es = []

for _ in range(m):

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

    a -= 1

    b -= 1

    es.append((a, b, c))

    cs[a][b] = cs[b][a] = c

for k in range(n):

    for i in range(n):

        for j in range(n):

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

print((sum([1 for a, b, c in es if cs[a][b] != c])))
n, m = list(map(int, input().split()))

cs = [[float('inf')] * n for _ in range(n)]

ns = [[0] * n for _ in range(n)]

for i in range(n):

    cs[i][i] = 0

for _ in range(m):

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

    a -= 1

    b -= 1

    cs[a][b] = cs[b][a] = c

    ns[a][b] = b

    ns[b][a] = a

for k in range(n):

    for i in range(n):

        for j in range(n):

            s = cs[i][k] + cs[k][j]

            if s < cs[i][j]:

                cs[i][j] = s

                ns[i][j] = ns[i][k]

used = set()

for i in range(n):

    for j in range(i + 1, n):

        path = [i]

        while path[-1] != j:

            s = path[-1]

            t = ns[s][j]

            path.append(t)

            used.add(tuple(sorted([s, t])))

print((m - len(used)))
n, m = list(map(int, input().split()))
cs = [[float("inf")] * n for _ in range(n)]
for i in range(n):
    cs[i][i] = 0
es = []
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    es.append((a, b, c))
    cs[a][b] = cs[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j])
print((sum([1 for a, b, c in es if cs[a][b] != c])))

n, m = list(map(int, input().split()))
cs = [[float("inf")] * n for _ in range(n)]
ns = [[0] * n for _ in range(n)]
for i in range(n):
    cs[i][i] = 0
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    cs[a][b] = cs[b][a] = c
    ns[a][b] = b
    ns[b][a] = a
for k in range(n):
    for i in range(n):
        for j in range(n):
            s = cs[i][k] + cs[k][j]
            if s < cs[i][j]:
                cs[i][j] = s
                ns[i][j] = ns[i][k]
used = set()
for i in range(n):
    for j in range(i + 1, n):
        path = [i]
        while path[-1] != j:
            s = path[-1]
            t = ns[s][j]
            path.append(t)
            used.add(tuple(sorted([s, t])))
print((m - len(used)))

+ns = [[0] * n for _ in range(n)] -es = [] -    es.append((a, b, c)) +    ns[a][b] = b +    ns[b][a] = a -            cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j]) -print((sum([1 for a, b, c in es if cs[a][b] != c]))) +            s = cs[i][k] + cs[k][j] +            if s < cs[i][j]: +                cs[i][j] = s +                ns[i][j] = ns[i][k] +used = set() +for i in range(n): +    for j in range(i + 1, n): +        path = [i] +        while path[-1] != j: +            s = path[-1] +            t = ns[s][j] +            path.append(t) +            used.add(tuple(sorted([s, t]))) +print((m - len(used)))