Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.

Neko has two integers a and b. His goal is to find a non-negative integer k such that the least common multiple of a+k and b+k is the smallest possible. If there are multiple optimal integers k, he needs to choose the smallest one.

Given his mathematical talent, Neko had no trouble getting Wrong Answer on this problem. Can you help him solve it?

Input

The only line contains two integers a and b (1 ≤ a, b ≤ 10^9).

Output

Print the smallest non-negative integer k (k ≥ 0) such that the lowest common multiple of a+k and b+k is the smallest possible.

If there are many possible integers k giving the same value of the least common multiple, print the smallest one.

Examples

Input


6 10


Output


2

Input


21 31


Output


9

Input


5 10


Output


0

Note

In the first test, one should choose k = 2, as the least common multiple of 6 + 2 and 10 + 2 is 24, which is the smallest least common multiple possible.
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigInteger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.TreeSet;

public final class CF_554_D2_C
{





	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x; 
	}


	static long pgcd(long a,long b){
		if (b>a)
			return pgcd(b,a);
		while (b>0){
			long c=b;
			b=a%b;
			a=c;
		}
		return a;
	}


	static long mod=1000000007;

	// Global vars
	static BufferedWriter out;
	static InputReader reader;
	static int[] anc,rank,max,list;

	
	static void test() {
		log("testing");
		int MX=10000;
		for (int a=2;a<MX;a++) {
			for (int b=a;b<MX;b++) {
				long k1=solveSimpleBug(a,b);
				long k2=solve(a,b);
				if (k1!=k2) {
					log("Error");
					log(a+" "+b);
					log(k1+" vs "+k2);
					return;
				}
			}
		}
		log("done");
	}
	 
	static long solveBourrin(int a,int b) {
		long best=1000000000L;
		int tgt=-1;
		for (int k=0;k<a*b;k++) {
			long p=pgcd(a+k,b+k);
			long x=a+k;
			x/=p;
			x*=b+k;
			if (x<best) {
				best=x;
				tgt=k;
			}
		}
		//log(best+" with "+tgt);
		if (a<CX && b<CX) {
			cache[(int)a][(int)b]=tgt+1;
		}
		return tgt;
	}

	/*
	static long explore(long diff) {
		long best=Long.MAX_VALUE;
		for (long p=1;p*p<=diff;p++) {
			if (diff%p==0) {
				long[] tm=new long[]{p,(diff)/p};
				for (long d:tm) {
					long opt;
					long div=diff/d;
					if (d!=1) {
						opt=div*explore(diff/div);
					} else {

					}

				}
			}
		}
	}
	 */
	
	static int CX=1000;

	static long[][] cache;
	
static long solveSimpleBug(long a,long b) {
		
		
		//log(a+" "+b);
		if (a<CX && b<CX) {
			if (cache[(int)a][(int)b]>0)
				return cache[(int)a][(int)b]-1;
			

		}
		if (a<10 && b<10)
			return solveBourrin((int)a,(int)b);
		
		
		if (a<b) {
			long c=a;
			a=b;
			b=c;
		}
		//long best=Long.MAX_VALUE;
		BigInteger best=null;
		long tgt=Long.MAX_VALUE;
		
		if (a==b)
			return 0;

		for (long p=1;p*p<=a-b;p++) {
			if ((a-b)%p==0) {
				//log("p:"+p);
				long[] tm=new long[]{p,(a-b)/p};
				for (long d:tm) {
					if (true) {
						long div=(a-b)/d;
						long beta=b/d;
						if (beta*d<b)
							beta++;
						long alpha=beta+div;
						long alphamin=a/d;
						if (alphamin*d<a)
							alphamin++;
						if (alpha<alphamin) {
							beta+=alphamin-alpha;
							alpha=alphamin;
						}
						
						//long q=pgcd(alpha,beta);
						long q=1;
						long k=alpha*d-a;

						//BigInteger Q=new BigInteger(""+Q);
						BigInteger AQ=new BigInteger(""+(alpha/q));
						BigInteger B=new BigInteger(""+beta);

						BigInteger D=new BigInteger(""+d);
						BigInteger ppcm=AQ.multiply(B).multiply(D);

						if (best==null) {
							best=ppcm;
							tgt=k;
						} else {
							if (ppcm.compareTo(best)<0) {
								best=ppcm;
								tgt=k;
							} else if (ppcm.compareTo(best)==0) {
								if (tgt>k)
									tgt=k;
							}
						}
					}
				}
			}
		}
		if (a<CX && b<CX) {
			cache[(int)a][(int)b]=tgt+1;
		}
		return tgt;
	}
	
	static long solve(long a,long b) {
		
		
		//log(a+" "+b);
		if (a<CX && b<CX) {
			if (cache[(int)a][(int)b]>0)
				return cache[(int)a][(int)b]-1;
			

		}
		if (a<10 && b<10)
			return solveBourrin((int)a,(int)b);
		
		
		if (a<b) {
			long c=a;
			a=b;
			b=c;
		}
		//long best=Long.MAX_VALUE;
		BigInteger best=null;
		long tgt=Long.MAX_VALUE;
		
		if (a==b)
			return 0;

		for (long p=1;p*p<=a-b;p++) {
			if ((a-b)%p==0) {
				//log("p:"+p);
				long[] tm=new long[]{p,(a-b)/p};
				for (long d:tm) {
					if (true) {
						long div=(a-b)/d;
						long beta=b/d;
						if (beta*d<b)
							beta++;
						long alpha=beta+div;
						long alphamin=a/d;
						if (alphamin*d<a)
							alphamin++;
						if (alpha<alphamin) {
							beta+=alphamin-alpha;
							alpha=alphamin;
						}
						long kk=0;
						//log("alpha:"+alpha+" beta:"+beta);
						if (alpha<a || beta<b)
							kk=solve(alpha,beta);
						alpha+=kk;
						beta+=kk;
						long q=pgcd(alpha,beta);

						long k=alpha*d-a;

						//BigInteger Q=new BigInteger(""+Q);
						BigInteger AQ=new BigInteger(""+(alpha/q));
						BigInteger B=new BigInteger(""+beta);

						BigInteger D=new BigInteger(""+d);
						BigInteger ppcm=AQ.multiply(B).multiply(D);

						if (best==null) {
							best=ppcm;
							tgt=k;
						} else {
							if (ppcm.compareTo(best)<0) {
								best=ppcm;
								tgt=k;
							} else if (ppcm.compareTo(best)==0) {
								if (tgt>k)
									tgt=k;
							}
						}
					}
				}
			}
		}
		if (a<CX && b<CX) {
			cache[(int)a][(int)b]=tgt+1;
		}
		return tgt;
	}

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader = new InputReader(System.in);

		
			cache=new long[CX][CX];
		
		//test();

		int a=reader.readInt();
		int b=reader.readInt();
		

		
		//log(solveBourrin(a,b));
		if (a<b) {
			int c=a;
			a=b;
			b=c;
		}
		//long best=Long.MAX_VALUE;

		output(solveSimpleBug(a,b));




		try {
			out.close();
		} catch (Exception e) {
		}

	}

	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg = false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d = (char) c;
			// log("d:"+d);
			if (d == '-') {
				neg = true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			// log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}