import Data.Ord
import Data.List

main = interact $ unlines . map (show . carden_lantern) . read' . lines
 where
  read' ("0":_) = []
  read' (n:m:xs) = (read n, map (parse . map read . splitOn ',') edge) : read' xs'
   where
    (edge,xs') = splitAt (read m) xs
    parse [a,b,d] = ((a,b), div d 100)

carden_lantern (n,edge) = count $ kruskal n $ sortBy (comparing snd) edge
 where count abd =  sum (map snd abd) - length abd

kruskal n edge = makepath (map return [0..n-1]) [] edge
 where
  makepath ts acc [] = acc
  makepath ts acc (((a,b),d):abd)
   | disjoint a b ts = makepath (link a b ts) ((((a,b),d)):acc) abd
   | otherwise = makepath ts acc abd
   where
    disjoint a b = not . any (\t -> elem a t && elem b t)
    link a b ts = let (ab,ts') = partition (\t -> elem a t || elem b t) ts in concat ab : ts'

splitOn c xs
 | null xs = []
 | head xs == c = splitOn c (tail xs)
 | otherwise = (takeWhile (/= c)) xs : splitOn c (dropWhile (/= c) xs)