
main = do
  [s,c] <- map read . words <$> getLine
  if s < c then 
    let cc = c - s * 2 in
    let ccc = cc `div` 4 in
    print $ s + ccc
  else
    let cc = s - c in
    let ccc = cc `div` 4 in
    print $ s + ccc
