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

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