main::IO()
main = do
  [a,b] <- map read . words <$> getLine
  putStrLn $ show $ solve a b

solve :: Int -> Int -> Int
solve s c = do
  let c2 =  c `div` 2
  case s > c2 of
    True -> c2
    False -> (c2 + s) `div` 2