import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
import Data.IORef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

type UnionFind = IOUArray Int Int
newUnionFind :: Int -> IO UnionFind
newUnionFind n = newArray (0,n-1) (-1)
root :: UnionFind -> Int -> IO Int
root uf i = do
    p <- readArray uf i
    if p<0 then return i else root uf p
same :: UnionFind -> Int -> Int -> IO Bool
same uf i j = (==) <$> root uf i <*> root uf j
unite :: UnionFind -> Int -> Int -> IO ()
unite uf i j = root uf i >>= writeArray uf j

main = do
    n <- getInt
    when (n/=0) $ do
        m <- getInt
        list <- sortBy (on compare (!!2)) . map (map readInt . wordsBy (==',')) <$> replicateM m getLine
        ref <- newIORef 0
        uf <- newUnionFind n
        forM_ list $ \[a,b,d] -> do
            c <- not <$> same uf a b
            when c $ do
                unite uf a b
                modifyIORef ref (+(div d 100 - 1))
        readIORef ref >>= print