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 javafx.util.*;
import java.util.*;
import java.io.*;
import java.math.*;

public class Test5 {

    PrintWriter pw = new PrintWriter(System.out);

    void run() {
        long a = nl(), b = nl(), p, o = Long.MAX_VALUE, d1,d2, c;
        ArrayList<Long> lab = GetDel.get(a+b), la = GetDel.get(a), lb = GetDel.get(b);
        p = 0;
        boolean can = false;
        for(; p<lab.size(); p++, can = false){
            d1 = lab.get((int)p);
            d2 = (a+b)/d1;
            c = la.size()-1;
            for(; c>=0 && !can; c--){
                if(can(la.get((int)c), a/la.get((int)c), d1,d2)) can = true;
            }
            c = lb.size()-1;
            for(; c>=0 && !can; c--){
                if(can(lb.get((int)c), b/lb.get((int)c), d1,d2)) can = true;
            }
            if(can) o = Math.min(o, (d1+d2)*2);
        }
        pw.print(o);
        pw.flush();
    }

    boolean can(long a, long b, long d1, long d2){
        return Math.max(a,b)<=Math.max(d1,d2) && Math.min(a,b)<= Math.min(d1,d2);
    }

    static class GetDel {

        static ArrayList<Long> k = new ArrayList<>();
        static long[] m;

        static ArrayList<Long> get(long ch){
            k = new ArrayList<>();
            long c=1, del=1;
            int ks=0;
            ArrayList<Long> otv = new ArrayList<>();
            ArrayList<Long> t = f(ch);
            ks = k.size();
            m = new long[ks];
            long[] dl = new long[ks];
            long[] itr = new long[ks];
            for(int q=0; q<ks; q++) {
                m[q] = k.get(q);
                dl[q] = t.get(q);
                del*=k.get(q)+1;
            }
            for(; del>0; c=1, del--){
                for(int w=ks-1; w>=0; w--){
                    itr[w]++;
                    if(itr[w]>m[w]) {
                        itr[w]=0;
                    }
                    else break;
                }
                for(int u=0; u<ks; u++) c*=(long)Math.pow(dl[u], itr[u]);
                otv.add(c);
            }
            Collections.sort(otv);
            return otv;
        }


        static ArrayList<Long> f(long a){
            ArrayList<Long> l = new ArrayList<>();
            for(long d = 2; d*d<=a || d<4; d++){
                if(a%d<1){
                    long u=0;
                    for(; a%d<1; ) {a/=d; u++;}
                    l.add(d);
                    k.add(u);
                }
            }
            for(long d=6; d*d<=a; d+=6){
                if(a%(d-1)<1){
                    long u=0;
                    for(; a%(d-1)<1; ) {a/=(d-1); u++;}
                    l.add(d-1);
                    k.add(u);
                }
                if(a%(d+1)<1){
                    long u=0;
                    for(; a%(d+1)<1; ) {a/=(d+1); u++;}
                    l.add(d+1);
                    k.add(u);
                }
            }
            if(a>1) {
                if(l.size()<1) {l.add(a); k.add((long)1);}
                else{
                    if(l.get(l.size()-1)!=a) {l.add(a); k.add((long)1);}
                    else{
                        k.add(k.get(k.size()-1)+1);
                        k.remove(k.size()-2);
                    }
                }
            }
            return l;
        }
    }

    public static void main(String[] args) {
        new Test5().run();
    }

    void print(int[][] m){
        for(int[] p : m){
            for(long i : p) pw.print(i+" ");
            pw.println();
        }
        pw.println();
    }

    InputStream is = System.in;
    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
}