H, W = map(int, input().split()) if H == 0 or W == 0: print(0) else: W_abs = abs(W) if W_abs <= H: print(H + W_abs - 1) else: print(2 * W_abs - H)