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