Problem: There is an infinite board of square tiles. Initially all tiles are white.

Vova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't use marker of any color on it. Each marker must be drained completely, so at the end there should be exactly a red tiles and exactly b blue tiles across the board.

Vova wants to color such a set of tiles that:

  * they would form a rectangle, consisting of exactly a+b colored tiles; 
  * all tiles of at least one color would also form a rectangle. 



Here are some examples of correct colorings:

<image>

Here are some examples of incorrect colorings:

<image>

Among all correct colorings Vova wants to choose the one with the minimal perimeter. What is the minimal perimeter Vova can obtain?

It is guaranteed that there exists at least one correct coloring.

Input

A single line contains two integers a and b (1 ≤ a, b ≤ 10^{14}) — the number of tiles red marker should color and the number of tiles blue marker should color, respectively.

Output

Print a single integer — the minimal perimeter of a colored rectangle Vova can obtain by coloring exactly a tiles red and exactly b tiles blue.

It is guaranteed that there exists at least one correct coloring.

Examples

Input

4 4


Output

12


Input

3 9


Output

14


Input

9 3


Output

14


Input

3 6


Output

12


Input

506 2708


Output

3218

Note

The first four examples correspond to the first picture of the statement.

Note that for there exist multiple correct colorings for all of the examples.

In the first example you can also make a rectangle with sides 1 and 8, though its perimeter will be 18 which is greater than 8.

In the second example you can make the same resulting rectangle with sides 3 and 4, but red tiles will form the rectangle with sides 1 and 3 and blue tiles will form the rectangle with sides 3 and 3.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {

    private static final long MOD = 998244353;

    static int[] readArray(int size, InputReader in, boolean subOne) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextInt() + (subOne ? -1 : 0);
        }
        return a;
    }

    static long[] readLongArray(int size, InputReader in) {
        long[] a = new long[size];
        for (int i = 0; i < size; i++) {
            a[i] = in.nextLong();
        }
        return a;
    }

    static void sortArray(int[] a) {
        Random random = new Random();

        for (int i = 0; i < a.length; i++) {
            int randomPos = random.nextInt(a.length);
            int t = a[i];
            a[i] = a[randomPos];
            a[randomPos] = t;
        }
        Arrays.sort(a);
    }


    public static void main(String[] args) throws FileNotFoundException {
//        InputReader in = new InputReader(new FileInputStream("input.txt"));
//        PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream("milkvisits.out")));
//
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        long a = in.nextLong();
        long b = in.nextLong();
        long s = a + b;
        long d = 1;
        long bestP = Long.MAX_VALUE;
        List<Long> divA = getDivisors(a);
        List<Long> divB = getDivisors(b);

        while (d * d <= s) {
            if (s % d == 0) {
                bestP = Math.min(perimeter(d, s, a, b, divA, divB), bestP);
                bestP = Math.min(perimeter(s / d, s, a, b, divA, divB), bestP);
            }
            d += 1;
        }
        out.println(bestP);

        out.close();
    }

    private static List<Long> getDivisors(long a) {
        long d = 1;
        ArrayList<Long> res = new ArrayList<>();
        ArrayList<Long> other = new ArrayList<>();

        while (d * d <= a) {
            if (a % d == 0) {
                res.add(d);
                if (a / d != d) {
                    other.add(a / d);
                }
            }
            d += 1;
        }
        for (int i = other.size() - 1; i >= 0; i--) {
            res.add(other.get(i));
        }
        return res;
    }

    private static long perimeter(long x, long s, long a, long b, List<Long> divA, List<Long> divB) {
        if (check(x, s, a, divA) || check(x, s, b, divB)) {
            return 2 * (x + s / x);
        }
        return Long.MAX_VALUE;
    }

    private static boolean check(long x, long s, long a, List<Long> divA) {
        int ind = binSearchRight(divA, x, 0, divA.size());
        if (ind >= 0 && ind < divA.size()) {
            long y = a / divA.get(ind);
            return y <= s / x;
        }
        return false;
    }

    static int binSearchRight(List<Long> list, long key, int start, int end) {
        int l = start - 1;
        int r = end;
        while (l < r - 1) {
            int m = (l + r) / 2;
            if (list.get(m) <= key) {
                l = m;
            } else {
                r = m;
            }
        }
        return l;
    }

    private static void outputArray(int[] ans, PrintWriter out, boolean addOne) {
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < ans.length; i++) {
            long an = ans[i] + (addOne ? 1 : 0);
            str.append(an).append(' ');
        }
        out.println(str);
    }

    private static void outputArray(List<Integer> ans, PrintWriter out, boolean addOne) {
        StringBuilder str = new StringBuilder();
        for (int j = 0; j < ans.size(); j++) {
            long i = ans.get(j);
            long an = i + (addOne ? 1 : 0);
            str.append(an);
            if (j < ans.size() - 1) {
                str.append(' ');
            }
        }
        out.println(str);
//        out.flush();
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextString() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

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

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

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

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextWord() {
            return next();
        }

        private List<Integer>[] readTree(int n) {
            return readGraph(n, n - 1);
        }

        private List<Integer>[] readGraph(int n, int m) {
            List<Integer>[] result = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                result[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                result[u].add(v);
                result[v].add(u);
            }
            return result;
        }

        private Map<Integer, Long>[] readWeightedGraph(int n, int m) {
            Map<Integer, Long>[] result = new HashMap[n];
            for (int i = 0; i < n; i++) {
                result[i] = new HashMap<>();
            }
            for (int i = 0; i < m; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                long w = nextLong();
                result[u].put(v, Math.min(w, result[u].getOrDefault(v, Long.MAX_VALUE)));
                result[v].put(u, Math.min(w, result[v].getOrDefault(u, Long.MAX_VALUE)));
            }
            return result;
        }

    }
}