main :: IO ()
main = fmap (map read . words) getLine >>= \[x,y] -> print $ ans' x y

ans' :: Int -> Int -> Int
ans' m n = if m <= q then g (n-m*2) m else q where
  q = n `div` 2
  g :: Int -> Int -> Int
  g s m = m + s `div` 4
