main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine
    answer $ solve n m

type Answer = Int
answer :: Answer -> IO ()
answer = print

solve :: Int -> Int -> Answer
solve n m
  | n * 2 > m = m `div` 2
  | otherwise = n + (m - n * 2) `div` 4

