main = do
  [s,c] <- map read . words <$> getLine :: IO [Int]
  print $ solve s c 

solve :: Int -> Int -> Int
solve s c 
  | c < 2 = 0
  | s >= (c`div`2) = c`div`2
  | otherwise = s + (c-2*s) `div` 4