H, W = map(int, input().split()) abs_W = abs(W) if H >= abs_W: print(2 * abs_W) else: print(2 * (abs_W - H))