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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author BSRK Aditya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        FMulticoloredMarkers solver = new FMulticoloredMarkers();
        solver.solve(1, in, out);
        out.close();
    }

    static class FMulticoloredMarkers {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long a = in.readLong(), b = in.readLong();

            //ArrayList<Long> aF = new ArrayList<>(), bF = new ArrayList<>();
            TreeSet<Long> aF = new TreeSet<>(), bF = new TreeSet<>();

            for (long i = 1; i * i <= a; ++i)
                if (a % i == 0) {
                    aF.add(i);
                    aF.add(a / i);
                }
            for (long i = 1; i * i <= b; ++i)
                if (b % i == 0) {
                    bF.add(i);
                    bF.add(b / i);
                }

            //Collections.sort(aF);
            //Collections.sort(bF);

            long ans = Long.MAX_VALUE;

            long sum = a + b;

            for (long s1 = 1; s1 * s1 <= sum; s1++) {
                if (sum % s1 == 0) {
                    long s2 = sum / s1;
                    //if (s1 + s2 == (199999999999948L/2L)) {
                    //   continue;
                    //}

                    Long factor = aF.floor(s1);
                    if (factor != null && a / factor <= s2)
                        ans = Long.min(ans, s1 + s2);

                    factor = bF.floor(s1);
                    if (factor != null && b / factor <= s2)
                        ans = Long.min(ans, s1 + s2);

                /*int idx = Collections.binarySearch(aF, s1);
                if (idx < 0) idx = - idx - 1;
                if (idx >= 0 && idx < aF.size()) {
                    if (a/aF.get(idx) <= s2) ans = Long.min(ans, s1 + s2);
                }

                idx = Collections.binarySearch(bF, s1);
                if (idx < 0) idx = - idx - 1;
                if (idx >= 0 && idx < bF.size()) {
                    if (b/bF.get(idx) <= s2) ans = Long.min(ans, s1 + s2);
                }*/
                }
            }
            out.printLine(2 * ans);
        }

    }

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

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

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}