import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (map read .words) >>= print

solve :: [Integer] -> Integer
solve [n, m]
  | 2 * n <= m = n + (m - 2 * n) `div` 4
  | otherwise = m `div` 2

getl :: (String -> a) -> IO a
getl f = f <$> getLine
