from strutils import split, parseInt, parseFloat
from sequtils import map

import macros
macro unpack(input: seq; count: static[int]): untyped =
  result = quote do: ()
  when NimMinor <= 13: # 本当にここが区切りかどうかは知らない
    for i in 0..<count: result[0].add quote do: `input`[`i`]
  else:
    for i in 0..<count: result.add quote do: `input`[`i`]

type UnselectableTypeError = object of Exception
template input(typ: typedesc; count: static[range[2..high(int)]]): untyped =
  let line = stdin.readLine.split
  when typ is int:    line.map(parseInt).unpack(count)
  elif typ is float:  line.map(parseFloat).unpack(count)
  elif typ is string: line.unpack(count)
  else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string")


from sequtils import mapIt, newSeqWith
from algorithm import fill

let
  (N, M) = input(int, 2)
  tmp = (0..<M).mapIt(input(int, 3))
  g: seq[tuple[a, b, c: int]] = tmp.mapIt((it[0] - 1, it[1] - 1, it[2]))

var
  dist = newSeqWith(N, newSeq[int](N))

for i, _ in dist:
  dist[i].fill(int.high div 3) # 適当に大きい値
  dist[i][i] = 0

for i in 0..<M:
  dist[g[i].a][g[i].b] = min(dist[g[i].a][g[i].b], g[i].c)
  dist[g[i].b][g[i].a] = min(dist[g[i].b][g[i].a], g[i].c)

echo dist

for k in 0..<N:
  for i in 0..<N:
    for j in 0..<N:
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

var result = 0
for gi in g:
   if dist[gi.a][gi.b] < gi.c:
    result.inc

echo result
