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

getsolve :: Integer -> Integer -> Integer
-- Sの個数→Cの個数→SCCのできる個数
getsolve _ 0 = 0
getsolve _ 1 = 0
getsolve 0 cnum = div cnum 4
getsolve snum cnum = makescc + getsolve (snum - makescc) (cnum - (makescc * 2))
    where makescc = min snum (div cnum 2)
