calc :: Integer -> Integer -> Integer
calc n m = if m < 2 * n
  then m `div` 2
  else n + (m - 2 * n) `div` 4


main :: IO ()
main = do
  line <- getLine
  let nums = map read $ words line :: [Integer]
      (n:m:[]) = nums
  print $ calc n m
