{-# LANGUAGE MultiWayIf #-}
import Control.Applicative ((<$>))

main = do
  [n,m] <- map read.words <$> getLine :: IO [Int]
  print $ if | m > n*2 -> n+(m-n*2)`div`4
             | otherwise -> m`div`2
