ans n m
  | m < 2 * n = div m 2
  | m == 2 * n = n
  | m > 2 * n = n + (div (m - 2 * n) 4)

main = do line <- getLine
          let [n',m'] = words line
              n = (read :: String -> Int) n'
              m = (read :: String -> Int) m' in
            putStrLn . show $ ans n m
