import os

import sys



import numpy as np

from scipy.sparse.csgraph import csgraph_from_dense, dijkstra



if os.getenv("LOCAL"):

    sys.stdin = open("_in.txt", "r")



sys.setrecursionlimit(2147483647)

INF = float("inf")

IINF = 10 ** 18



N, M = list(map(int, sys.stdin.readline().split()))

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



D = np.zeros((N, N))

for a, b, c in ABC:

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



min_dist = dijkstra(csgraph_from_dense(D), directed=False)

print(((min_dist < D).sum()))

import os

import sys



import numpy as np



if os.getenv("LOCAL"):

    sys.stdin = open("_in.txt", "r")



sys.setrecursionlimit(2147483647)

INF = float("inf")

IINF = 10 ** 18



N, M = list(map(int, sys.stdin.readline().split()))

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



D = np.full((N, N), IINF)

for a, b, c in ABC:

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

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



# warshall floyd

for via in range(N):

    D = np.minimum(D, sum(np.meshgrid(D[via], D[via], sparse=True)))



ans = 0

for a, b, c in ABC:

    if D[a - 1][b - 1] < c:

        ans += 1

print(ans)

import os
import sys
import numpy as np
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
N, M = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
D = np.zeros((N, N))
for a, b, c in ABC:
    D[a - 1][b - 1] = c
min_dist = dijkstra(csgraph_from_dense(D), directed=False)
print(((min_dist < D).sum()))

import os
import sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10**18
N, M = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
D = np.full((N, N), IINF)
for a, b, c in ABC:
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c
# warshall floyd
for via in range(N):
    D = np.minimum(D, sum(np.meshgrid(D[via], D[via], sparse=True)))
ans = 0
for a, b, c in ABC:
    if D[a - 1][b - 1] < c:
        ans += 1
print(ans)

-from scipy.sparse.csgraph import csgraph_from_dense, dijkstra -D = np.zeros((N, N)) +D = np.full((N, N), IINF) -min_dist = dijkstra(csgraph_from_dense(D), directed=False) -print(((min_dist < D).sum())) +    D[b - 1][a - 1] = c +# warshall floyd +for via in range(N): +    D = np.minimum(D, sum(np.meshgrid(D[via], D[via], sparse=True))) +ans = 0 +for a, b, c in ABC: +    if D[a - 1][b - 1] < c: +        ans += 1 +print(ans)