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.IO

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

inf = 1000000000

solve [] _ a = a
solve ([a,b,c]:es) arr acc = solve es arr acc'
  where
    acc' = acc + (if arr!(a,b) /= c then 1 else 0)

main = do
  [n,m] <- getInts
  dt <- newArray ((1,1),(n,n)) inf :: IO (IOArray (Int,Int) Int)
  es <- replicateM m getInts
  forM_ es $ \[a,b,c] -> do
    writeArray dt (a,b) c
    writeArray dt (b,a) c
  forM_ [1..n] $ \k -> do
    forM_ [1..n] $ \i -> do
      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))
  arr <- freeze dt :: IO (Array (Int,Int) Int)
  print $ solve es arr 0
