main = do
  li <- getLine
  let [s,c] = map read $ words li
  let ans = compute s c
  print ans

compute :: Int -> Int -> Int
compute s c
  | d >= 0 = s + d `div` 4
  | True   = c `div` 2
  where
    d = c - 2 * s

{-
 c + c -> S
 if 2s <= c, s + (c-2s)/4
 otherwise, c/2
-}
