import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.Array.IArray
import Data.Array.ST

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

inf = 1000000000
wf n es = runSTUArray $ do
  dt <- newArray ((1,1),(n,n)) inf-- :: ST s (STArray (Int,Int) Int)
  forM_ es $ \[a,b,c] -> do
    writeArray dt (a,b) c
    writeArray dt (b,a) c
  forM_ [1..n] $ \k ->
    forM_ [1..n] $ \i ->
      forM_ [1..n] $ \j -> do
        a <- readArray dt (i,k)
        b <- readArray dt (k,j)
        pv <- readArray dt (i,j)
        writeArray dt (i,j) (min pv (a+b))
  return dt
solve es arr = length [() | [a,b,c] <- es, arr!(a,b) /= c]

main = do
  [n,m] <- getInts
  es <- replicateM m getInts
  let arr = wf n es
  print $ solve es arr
