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



A = [[9999 for _ in range(N)] for _ in range(N)]

B = []

for i in range(M):

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

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

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

    B.append((a-1,b-1,c))



for k in range(N):

    for i in range(N):

        for j in range(N):

            if i==j:

                A[i][j] = 0

            else:

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



ans = 0

for i in range(M):

    a,b,c = B[i]

    for j in range(N):

        if A[j][b] == A[j][a] + c:

            break

    else:

        ans += 1



print(ans)
# python3 (3.4.3)

import sys

input = sys.stdin.readline



# main

from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

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

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



g = [[0 for _ in range(N)] for _ in range(N)]



for a,b,c in ABC:

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



csg = csgraph_from_dense(g)

d = floyd_warshall(csg, directed=False)



ans = 0

for a,b,c in ABC:

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

        ans += 1



print(ans)
N, M = list(map(int, input().split()))
A = [[9999 for _ in range(N)] for _ in range(N)]
B = []
for i in range(M):
    a, b, c = list(map(int, input().split()))
    A[a - 1][b - 1] = c
    A[b - 1][a - 1] = c
    B.append((a - 1, b - 1, c))
for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j:
                A[i][j] = 0
            else:
                A[i][j] = min(A[i][j], A[i][k] + A[k][j])
ans = 0
for i in range(M):
    a, b, c = B[i]
    for j in range(N):
        if A[j][b] == A[j][a] + c:
            break
    else:
        ans += 1
print(ans)

# python3 (3.4.3)
import sys

input = sys.stdin.readline
# main
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

N, M = list(map(int, input().split()))
ABC = [list(map(int, input().split())) for _ in range(M)]
g = [[0 for _ in range(N)] for _ in range(N)]
for a, b, c in ABC:
    g[a - 1][b - 1] = c
csg = csgraph_from_dense(g)
d = floyd_warshall(csg, directed=False)
ans = 0
for a, b, c in ABC:
    if c != d[a - 1][b - 1]:
        ans += 1
print(ans)

+# python3 (3.4.3) +import sys + +input = sys.stdin.readline +# main +from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall + -A = [[9999 for _ in range(N)] for _ in range(N)] -B = [] -for i in range(M): -    a, b, c = list(map(int, input().split())) -    A[a - 1][b - 1] = c -    A[b - 1][a - 1] = c -    B.append((a - 1, b - 1, c)) -for k in range(N): -    for i in range(N): -        for j in range(N): -            if i == j: -                A[i][j] = 0 -            else: -                A[i][j] = min(A[i][j], A[i][k] + A[k][j]) +ABC = [list(map(int, input().split())) for _ in range(M)] +g = [[0 for _ in range(N)] for _ in range(N)] +for a, b, c in ABC: +    g[a - 1][b - 1] = c +csg = csgraph_from_dense(g) +d = floyd_warshall(csg, directed=False) -for i in range(M): -    a, b, c = B[i] -    for j in range(N): -        if A[j][b] == A[j][a] + c: -            break -    else: +for a, b, c in ABC: +    if c != d[a - 1][b - 1]: