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