def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) a, b = sorted(map(int, raw_input().split())) if(a == b or a == 0): print 1 elif(a == 1 or (a < b-a)): n = a + 1 while n <= (b-a): if((b-a) % n == 0): print n - a break n = n + 1 else: print b-a - a%(b-a)