Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.

The students don’t want to use too many blocks, but they also want to be unique, so no two students’ towers may contain the same number of blocks. Find the minimum height necessary for the tallest of the students' towers.

Input

The first line of the input contains two space-separated integers n and m (0 ≤ n, m ≤ 1 000 000, n + m > 0) — the number of students using two-block pieces and the number of students using three-block pieces, respectively.

Output

Print a single integer, denoting the minimum possible height of the tallest tower.

Examples

Input

1 3


Output

9


Input

3 2


Output

8


Input

5 0


Output

10

Note

In the first case, the student using two-block pieces can make a tower of height 4, and the students using three-block pieces can make towers of height 3, 6, and 9 blocks. The tallest tower has a height of 9 blocks.

In the second case, the students can make towers of heights 2, 4, and 8 with two-block pieces and towers of heights 3 and 6 with three-block pieces, for a maximum height of 8 blocks.

import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

public class CodeForces {

    static int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
    static int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        
        int a = Reader.nextInt(), b = Reader.nextInt();
        int ev = 0, x = 0;
        for (int i = 0; i < b; i++) {
            x += 3;
            if(x % 2 == 0)
                ev++;
        }
        
        int ans = (int)1e9;
        for (int i = 0; i <= ev; i++) {
            ans = Math.min(ans, Math.max(2*(ev-i+a), x));
            x+=3;
            if(2*(ev-i+a-1) >= x && x % 2 == 0)
                x+=3;
        }
        
        System.out.println(ans);
    }       
}

class Point{
    int x, y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class Warehouse{
    Point location;
    int arr[];

    public Warehouse(Point location, int p) {
        this.location = location;
        this.arr = new int[p];
    }
}

class Order{
    Point location;
    HashMap<Integer, Integer> map;
    
    public Order(Point location) {
        this.location = location;
        map = new HashMap<>();
    }
}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    public static int pars(String x) {
        int num = 0;
        int i = 0;
        if (x.charAt(0) == '-') {
            i = 1;
        }
        for (; i < x.length(); i++) {
            num = num * 10 + (x.charAt(i) - '0');
        }

        if (x.charAt(0) == '-') {
            return -num;
        }

        return num;
    }

    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static void init(FileReader input) {
        reader = new BufferedReader(input);
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return pars(next());
    }

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

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