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

inf=float("inf")



data=[[inf]*(n+1) for i in range(n+1)]

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

    data[i][i]=0

lst=[]

for u in range(m):

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

    data[a][b]=c

    data[b][a]=c

    lst.append([a,b,c])



for k in range(1,n+1):

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

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

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



ans=0

for u in lst:

    a,b,c=u

    if data[a][b]!=c:

        ans+=1



print(ans)
import numpy as np

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson

from scipy.sparse import csr_matrix



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

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



data=np.zeros((n+1,n+1))

for u in abc:

    a,b,c=u

    data[a,b]=c

    data[b,a]=c

qqq=shortest_path(data,directed=False).astype(int)



ans=0

for u in abc:

    a,b,c=u

    if qqq[a][b]!=c:

        ans+=1

print(ans)
n, m = list(map(int, input().split()))
inf = float("inf")
data = [[inf] * (n + 1) for i in range(n + 1)]
for i in range(1, n + 1):
    data[i][i] = 0
lst = []
for u in range(m):
    a, b, c = list(map(int, input().split()))
    data[a][b] = c
    data[b][a] = c
    lst.append([a, b, c])
for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            data[i][j] = min(data[i][j], data[i][k] + data[k][j])
ans = 0
for u in lst:
    a, b, c = u
    if data[a][b] != c:
        ans += 1
print(ans)

import numpy as np
from scipy.sparse.csgraph import (
    shortest_path,
    floyd_warshall,
    dijkstra,
    bellman_ford,
    johnson,
)
from scipy.sparse import csr_matrix

n, m = list(map(int, input().split()))
abc = [list(map(int, input().split())) for i in range(m)]
data = np.zeros((n + 1, n + 1))
for u in abc:
    a, b, c = u
    data[a, b] = c
    data[b, a] = c
qqq = shortest_path(data, directed=False).astype(int)
ans = 0
for u in abc:
    a, b, c = u
    if qqq[a][b] != c:
        ans += 1
print(ans)

+import numpy as np +from scipy.sparse.csgraph import ( +    shortest_path, +    floyd_warshall, +    dijkstra, +    bellman_ford, +    johnson, +) +from scipy.sparse import csr_matrix + -inf = float("inf") -data = [[inf] * (n + 1) for i in range(n + 1)] -for i in range(1, n + 1): -    data[i][i] = 0 -lst = [] -for u in range(m): -    a, b, c = list(map(int, input().split())) -    data[a][b] = c -    data[b][a] = c -    lst.append([a, b, c]) -for k in range(1, n + 1): -    for i in range(1, n + 1): -        for j in range(1, n + 1): -            data[i][j] = min(data[i][j], data[i][k] + data[k][j]) +abc = [list(map(int, input().split())) for i in range(m)] +data = np.zeros((n + 1, n + 1)) +for u in abc: +    a, b, c = u +    data[a, b] = c +    data[b, a] = c +qqq = shortest_path(data, directed=False).astype(int) -for u in lst: +for u in abc: -    if data[a][b] != c: +    if qqq[a][b] != c: