import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    xy <- VU.replicateM m $ do
        [x,y] <- getIntList
        return (x-1,y-1)
    let result = VU.create $ do
            balls <- VUM.replicate n (1 :: Int)
            red <- VUM.replicate n False
            VUM.write red 0 True
            VU.forM_ xy $ \(x,y) -> do
                VUM.modify balls pred x
                VUM.modify balls succ y
                nx <- VUM.read balls x
                cx <- VUM.read red x
                when (nx == 0) $ VUM.write red x False
                when cx $ VUM.write red y True
            return red
    print . VU.length $ VU.filter id result