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.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.io.InputStream ;
import java.util.InputMismatchException;
import java.util.ArrayList;

public class Main {
    static int maxn = (int)1e6+1;
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        //Scanner sc = new Scanner();
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();

    }
    
    
    void solve(PrintWriter out, Reader in) throws IOException{   
        long a = in.nextLong();
        long b = in.nextLong();
        long c = a+b;
        
        as = new ArrayList<Integer>();
        ba = new ArrayList<Integer>();
        
        for(int i=1 ;i<=(int)Math.sqrt(a);i++)
            if(a%i==0) as.add(i);
        for(int i=1 ;i<=(int)Math.sqrt(b);i++)
            if(b%i==0) ba.add(i);
        
        
        for(int i=(int)Math.sqrt(c) ;i>=1  ;i--){
            if(c%i==0 && (bs(a,i,c/i,as) || bs(b,i,c/i,ba))) {out.println(2*(i+c/i));return;} 
        }
        
            
    }
    
    static ArrayList<Integer> as,ba;
    
    static boolean bs(long d,long l,long L,ArrayList<Integer> list){
        int lo=0,hi=list.size()-1,mid;
        long max;
        
        while(lo<=hi){
            mid = (lo+hi)/2;
            if(list.get(mid)<=l) max = L;
            else max = l;
                
            
            if(max!=L) hi = mid-1;
            else if(d/list.get(mid)<=max) return true;
            else    lo =mid+1;
        }
        
        lo=0;
        hi=list.size()-1;
        
        while(lo<=hi){
            mid = (lo+hi)/2;
            if(list.get(mid)<=l) max = L;
            else max = l;
                
            if(max!=l) lo = mid+1;
            else if(d/list.get(mid)<=max) return true;
            else    lo =mid+1;
        }
        
        return false;
    }
    
    static class Node implements Comparable<Node>{
        int x,y;
        Node(int x, int y){
            this.x = x;
            this.y = y;
        }
        
        
        public int compareTo(Node o){
            return this.y - o.y;
        }
    }
    
    static class Reader {
 
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
     
        public Reader() {
            this(System.in);
        }
     
        public Reader(InputStream is) {
            mIs = is;
        }
     
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
        
        }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }
     
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
     
        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
     
        public long nextLong() {
            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 int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int 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) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
     
        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
    }
}