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.
//package com.company;
// Always comment out package when submitting.


import java.io.*;
import java.util.*;

public class Main {
    public static class Task {
        int sz = 1 << 20;
        int[] state;
        public long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }
        public void solve(Scanner sc, PrintWriter pw) throws IOException {
//            state = new int[sz];
//            Arrays.fill(state, -1);
//            for (int i = 0; i <= 20; i++) {
//                state[(1 << i) - 1] = 99;
//            }
//            int x = sc.nextInt();
//            state[x] = -2;
//            int[] quese = new int[sz + 1];
//            quese[0] = x;
//            int idx = 0;
//            int mv = 1;
//            while (idx < mv) {
//                int place = quese[idx];
//                idx++;
//                for (int i = 0; i <= 20; i++) {
//                    int visit = place ^ ((1 << i) - 1);
//                    if (state[visit] == -1) {
//                        state[visit] = i;
//                        quese[mv++] = visit;
//                        int nextVisit = visit + 1;
//                        if (state[nextVisit] == -1) {
//                            state[nextVisit] = 100;
//                            quese[mv++] = nextVisit;
//                        } else if (state[nextVisit] == 99) {
//                            int prevAt = visit;
//                            List<Integer> reverseDo = new ArrayList<>();
//                            int sz = 0;
//                            while (prevAt != x) {
//                                int op = state[prevAt];
//                                if (op == 100) {
//                                    prevAt--;
//                                    sz++;
//                                } else {
//                                    prevAt ^= (1 << op) - 1;
//                                    reverseDo.add(op);
//                                    sz++;
//                                }
//                            }
//                            pw.println(sz);
//                            for (int j = reverseDo.size() - 1; j >= 0; j--) {
//                                pw.print(reverseDo.get(j) + " ");
//                                pw.println();
//                            }
//                            return;
//                        }
//                    } else if (state[visit] == 99) {
//                        int prevAt = place;
//                        List<Integer> reverseDo = new ArrayList<>();
//                        while (prevAt != x) {
//                            int op = state[prevAt];
//                            if (op == 100) {
//                                prevAt--;
//                            } else {
//                                prevAt ^= (1 << op) - 1;
//                                reverseDo.add(op);
//                            }
//                        }
//                        pw.println(reverseDo.size() * 2);
//                        for (int j = reverseDo.size() - 1; j >= 0; j--) {
//                            pw.print(reverseDo.get(j) + " ");
//                            pw.println();
//                        }
//                        return;
//                    }
//                }
//            }

            int a = sc.nextInt();
            int b = sc.nextInt();
            if (a == b) {
                pw.println(0);
                return;
            }
            int c = Math.abs(a - b);
            long bestLCM = Long.MAX_VALUE;
            long bestK = Long.MAX_VALUE;
            for (int d = 1; d * d <= c; d++) {
                if (c % d != 0) continue;
                {
                    int x = (d + a - 1) / d;
                    int y = (d + b - 1) / d;
                    long k = (long) x * d - a;
                    if (k != (long) y * d - b) {
                        throw new RuntimeException();
                    }
                    long gcd = gcd(x, y);
                    if (gcd == 1) {
                        long lcm = (long) x * y * d;
                        if (lcm < bestLCM) {
                            bestLCM = lcm;
                            bestK = k;
                        } else if (lcm == bestLCM) {
                            bestK = Math.min(bestK, k);
                        }
                    }
                }
                {
                    int D = c / d;
                    int x = (D + a - 1) / D;
                    int y = (D + b - 1) / D;
                    long k = (long) x * D - a;
                    if (k != (long) y * D - b) {
                        throw new RuntimeException();
                    }
                    long gcd = gcd(x, y);
                    if (gcd != 1) continue;
                    long lcm = (long) x * y * D;
                    if (lcm < bestLCM) {
                        bestLCM = lcm;
                        bestK = k;
                    } else if (lcm == bestLCM) {
                        bestK = Math.min(bestK, k);
                    }
                }
            }
            pw.println(bestK);
        }
    }

    // template, actual code is in class Task.
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
//        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    // Faster IO with BufferedReader wrapped with Scanner
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}