-- Try yukicoder -- author: Leonardone @ NEETSDKASU main = interact $ show . solve . map read . words solve [a, b] = f True 1 a b f ex cnt 0 0 = if ex then max 1 (div cnt 2) else 0 f ex cnt a b = f e c ad bd where (ad, am) = divMod a 2 (bd, bm) = divMod b 2 e = ex && not (am == 1 && bm == 0) c = cnt * if am == 0 && bm == 1 then 2 else 1