a, b = map(int, input().split()) t = min(a, b) * 2 f = a + b - t cnt = f if t < f: print(abs(t - f)) else: tmp = abs(t - f) while abs((t - 1) - (f + 1)) < tmp and 0 <= t - 1 and 0 < cnt: cnt -= 1 t, f = t - 1, f + 1 tmp = abs((t) - (f)) print(tmp)