import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Graph


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,m] <- r'
    inps <- filter (>1) . map (length . components . toBiGraph n) . holed [] . map toTup <$> replicateM m r'
    print $ length inps

flipTup :: Edge -> Edge
flipTup (a,b) = (b,a)

toBiGraph :: Vertex -> [Edge] -> Graph
toBiGraph n xs = buildG (1,n) (map flipTup xs ++ xs)

holed ac []     = []
holed ac (x:xs) = (ac++xs):(holed (x:ac) xs)