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

inf = float("inf")

dp = [[inf]*N for _ in [0]*N]

for i in range(N):dp[i][i] = 0

d = [list(map(int, input().split())) for i in range(M)]

ans = 0

 

for a,b,c in d:

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

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

for k in range(N):

    for i in range(N):

        for j in range(N):

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

for a,b,c in d:

        if dp[a-1][b-1] != c:

            ans += 1

print(ans)

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

inf = float("inf")

dp = [[inf]*N for _ in [0]*N]

for i in range(N):dp[i][i] = 0

d = [list(map(int, input().split())) for i in range(M)]

ans = 0

from scipy.sparse.csgraph import floyd_warshall 

for a,b,c in d:

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

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

cost = floyd_warshall(dp)

for a,b,c in d:

        if cost[a-1][b-1] != c:

            ans += 1

print(ans)

N, M = list(map(int, input().split()))
inf = float("inf")
dp = [[inf] * N for _ in [0] * N]
for i in range(N):
    dp[i][i] = 0
d = [list(map(int, input().split())) for i in range(M)]
ans = 0
for a, b, c in d:
    dp[a - 1][b - 1] = c
    dp[b - 1][a - 1] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
for a, b, c in d:
    if dp[a - 1][b - 1] != c:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
inf = float("inf")
dp = [[inf] * N for _ in [0] * N]
for i in range(N):
    dp[i][i] = 0
d = [list(map(int, input().split())) for i in range(M)]
ans = 0
from scipy.sparse.csgraph import floyd_warshall

for a, b, c in d:
    dp[a - 1][b - 1] = c
    dp[b - 1][a - 1] = c
cost = floyd_warshall(dp)
for a, b, c in d:
    if cost[a - 1][b - 1] != c:
        ans += 1
print(ans)

+from scipy.sparse.csgraph import floyd_warshall + -for k in range(N): -    for i in range(N): -        for j in range(N): -            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]) +cost = floyd_warshall(dp) -    if dp[a - 1][b - 1] != c: +    if cost[a - 1][b - 1] != c: