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

abc= [list(map(int,input().split())) for _ in [0]*M]

d = [[10000*N]*N for _ in [0]*N]

for a,b,c in abc:

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

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

for k in range(N):

    for i in range(N):

        for j in range(N):

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

ans=sum(d[a-1][b-1]<c for a,b,c in abc)

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

ABC = [list(map(int,input().split())) for _ in [0]*M]

INF = 10**9

d = [[INF]*N for _ in [0]*N]

for i in range(N):

    d[i][i] = 0

for a,b,c in ABC:

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

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

def Warshall_Floyd(d,N=None):

    if N==None : N = len(d)

    for k in range(N):

        for i in range(N):

            for j in range(N):

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

Warshall_Floyd(d,N)

print((sum(d[a-1][b-1]!=c for a,b,c in ABC)))
N, M = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in [0] * M]
d = [[10000 * N] * N for _ in [0] * N]
for a, b, c in abc:
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = sum(d[a - 1][b - 1] < c for a, b, c in abc)
print(ans)

N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in [0] * M]
INF = 10**9
d = [[INF] * N for _ in [0] * N]
for i in range(N):
    d[i][i] = 0
for a, b, c in ABC:
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c


def Warshall_Floyd(d, N=None):
    if N == None:
        N = len(d)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])


Warshall_Floyd(d, N)
print((sum(d[a - 1][b - 1] != c for a, b, c in ABC)))

-abc = [list(map(int, input().split())) for _ in [0] * M] -d = [[10000 * N] * N for _ in [0] * N] -for a, b, c in abc: +ABC = [list(map(int, input().split())) for _ in [0] * M] +INF = 10**9 +d = [[INF] * N for _ in [0] * N] +for i in range(N): +    d[i][i] = 0 +for a, b, c in ABC: -for k in range(N): -    for i in range(N): -        for j in range(N): -            d[i][j] = min(d[i][j], d[i][k] + d[k][j]) -ans = sum(d[a - 1][b - 1] < c for a, b, c in abc) -print(ans) + + +def Warshall_Floyd(d, N=None): +    if N == None: +        N = len(d) +    for k in range(N): +        for i in range(N): +            for j in range(N): +                d[i][j] = min(d[i][j], d[i][k] + d[k][j]) + + +Warshall_Floyd(d, N) +print((sum(d[a - 1][b - 1] != c for a, b, c in ABC)))