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

solve :: Int -> Int -> Int
solve s c
  | s >= 2*c = s + (c-s) `div` 4
  | otherwise = 
    let 
      ccs = c `div` 2
    in
      if s >= ccs then s else s + (c-s*2) `div` 4
