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.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	public static void main(String[] args) throws IOException {
		//		Scanner in = new Scanner(new File("test"));
		Scanner in = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt(), m = in.nextInt();
		if (n == 0 && m == 0) {
			out.println(0);
		} else {
			int[] arr = new int[(m + n) * 5];
			int k1 = 1, k2 = 1;
			for (int i = 0; i < (n + m) * 5; i++) {
				if (k1 * 2 == k2 * 3) {
					arr[i] = k1 * 2;
					k1++;
					k2++;
				} else if (k1 * 2 < k2 * 3) {
					arr[i] = k1 * 2;
					k1++;
				} else {
					arr[i] = k2 * 3;
					k2++;
				}
			}

			int cnt = 0;
			int[] fill = new int[(n + m) * 5];
			int b1 = n, b2 = m;
			for (int i = 0; i < (n + m) * 5; i++) {
				if (arr[i] % 2 == 0 && arr[i] % 3 == 0) {
					cnt++;
					continue;
				}
				if (arr[i] % 2 == 0 && b1 > 0) {
					b1--;
					fill[i] = 1;
				} else if (arr[i] % 3 == 0 && b2 > 0) {
					b2--;
					fill[i] = 2;
				}
				cnt++;
			}
//					System.out.println(Arrays.toString(arr));
//					System.out.println(Arrays.toString(fill));
					cnt = (n + m) * 5 - 1;
			while (fill[cnt] == 0)
				cnt--;
//			out.println(arr[cnt]);
			for (int i = 3; i < cnt; i += 4) {
				if (arr[i] % 2 == 0 && arr[i] % 3 == 0) {
					fill[i] = 3;
					fill[cnt] = 0;
					cnt--;
					while (fill[cnt] == 0)
						cnt--;
				}
			}
//			for (int i = 0; i < 100; i++) {
//				if (fill[i] != 0)
//					out.print(arr[i] + " ");
//			}
//			out.println();
//					System.out.println(Arrays.toString(arr));
//					System.out.println(Arrays.toString(fill));

			out.println(arr[cnt]);
		}

		in.close();
		out.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws IOException {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		}

		public Scanner(File source) throws IOException {
			br = new BufferedReader(new FileReader(source));
			st = new StringTokenizer(br.readLine());
		}

		public int nextInt() throws IOException {
			while (!st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null)
					throw new IOException("No more ints");
				st = new StringTokenizer(s);
			}
			return Integer.parseInt(st.nextToken());
		}

		public long nextLong() throws IOException {
			while (!st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null)
					throw new IOException("No more ints");
				st = new StringTokenizer(s);
			}
			return Long.parseLong(st.nextToken());
		}

		public String next() throws IOException {
			while (!st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null)
					throw new IOException("No more ints");
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		public boolean hasNext() throws IOException {
			while (!st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}
