from collections import defaultdict

from heapq import heappush, heappop

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

dic = defaultdict(list)

Els = []

for i in range(M):

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

  dic[a-1] += [(b-1,c)]

  dic[b-1] += [(a-1, c)]

  Els += [(a-1,b-1,c)]



def dijkstra(s,e):

  dist = [float('inf')]*N

  dist[s] = 0

  q = [(0,s)]

  z = -1

  while q:

    c, v = heappop(q)

    if dist[v]<c:

      continue

    dist[v] = c

    for u, m in dic[v]:

      if dist[u]>dist[v]+m:

        dist[u] = dist[v]+m

        heappush(q,(dist[u],u))

        if u==e:

          z = v

  return z



ans = 0

for a, b, c in Els:

  if dijkstra(a,b)!=a:

    ans += 1

print(ans)
from scipy.sparse.csgraph import shortest_path

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

dic = [[0]*N for i in range(N)]

Els = []

for i in range(M):

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

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

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

  Els += [(a-1,b-1,c)]

d, p = shortest_path(dic, return_predecessors=True, method='D')



ans = 0

for a, b, c in Els:

  if p[a][b]!=a:

    ans += 1

print(ans)
from collections import defaultdict
from heapq import heappush, heappop

N, M = list(map(int, input().split()))
dic = defaultdict(list)
Els = []
for i in range(M):
    a, b, c = list(map(int, input().split()))
    dic[a - 1] += [(b - 1, c)]
    dic[b - 1] += [(a - 1, c)]
    Els += [(a - 1, b - 1, c)]


def dijkstra(s, e):
    dist = [float("inf")] * N
    dist[s] = 0
    q = [(0, s)]
    z = -1
    while q:
        c, v = heappop(q)
        if dist[v] < c:
            continue
        dist[v] = c
        for u, m in dic[v]:
            if dist[u] > dist[v] + m:
                dist[u] = dist[v] + m
                heappush(q, (dist[u], u))
                if u == e:
                    z = v
    return z


ans = 0
for a, b, c in Els:
    if dijkstra(a, b) != a:
        ans += 1
print(ans)

from scipy.sparse.csgraph import shortest_path

N, M = list(map(int, input().split()))
dic = [[0] * N for i in range(N)]
Els = []
for i in range(M):
    a, b, c = list(map(int, input().split()))
    dic[a - 1][b - 1] = c
    dic[b - 1][a - 1] = c
    Els += [(a - 1, b - 1, c)]
d, p = shortest_path(dic, return_predecessors=True, method="D")
ans = 0
for a, b, c in Els:
    if p[a][b] != a:
        ans += 1
print(ans)

-from collections import defaultdict -from heapq import heappush, heappop +from scipy.sparse.csgraph import shortest_path -dic = defaultdict(list) +dic = [[0] * N for i in range(N)] -    dic[a - 1] += [(b - 1, c)] -    dic[b - 1] += [(a - 1, c)] +    dic[a - 1][b - 1] = c +    dic[b - 1][a - 1] = c - - -def dijkstra(s, e): -    dist = [float("inf")] * N -    dist[s] = 0 -    q = [(0, s)] -    z = -1 -    while q: -        c, v = heappop(q) -        if dist[v] < c: -            continue -        dist[v] = c -        for u, m in dic[v]: -            if dist[u] > dist[v] + m: -                dist[u] = dist[v] + m -                heappush(q, (dist[u], u)) -                if u == e: -                    z = v -    return z - - +d, p = shortest_path(dic, return_predecessors=True, method="D") -    if dijkstra(a, b) != a: +    if p[a][b] != a: