import Data.Graph.Inductive
import Data.Graph.Inductive.Example( genUNodes)
import Control.Monad
import Data.List(foldl', sort)
import qualified Data.List as L
import Data.Set
import qualified Data.Set as S

main = do
    [n_, m_] <- return . L.map read . words =<< getLine
    let readEdge = do
	    [a,b,c] <- return . L.map read . words =<< getLine
	    return (a,b,c)
    edges <- replicateM m_ readEdge
    let 
	gr = mkGraph (genUNodes n_) edges	::Gr () Int
	edgeSet:: Set (Node,Node) -> Path ->  Set (Node,Node)
	edgeSet set [] = set
	edgeSet set [node] = set
	edgeSet set (node1:node2:path) = let
		nmax = max node1 node2
		nmin = min node1 node2
	    in edgeSet (insert (nmin,nmax) set) $ node2:path
	nds = sort $ nodes gr
	rtree = [sp n1 n2 (undir gr) | n1<-nds, n2<- dropWhile (<=n1) nds]
	lastSet = L.foldl' edgeSet S.empty rtree
    print $ m_ - (size lastSet)