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.*;
import java.util.*;
public class q3 {
	public static void main(String[] args) throws Exception
	{
		InputReader in=new InputReader(System.in);
		PrintWriter pw=new PrintWriter(System.out);

		long n=in.nextLong();
		long m=in.nextLong();
		pw.println(function(n,m));
		pw.close();
	}
	public static long function(long n,long m)
	{
		long l=0;
		long r=(long)(1e11);
		long minnum=r;
		while(l<=r)
		{
			long mid=(l+r)>>1;
			if(l==r || l+1==r)
			{
			if(ispossible(l,n,m))
			{
				minnum=Math.min(minnum,l);
			}
			if(ispossible(r,n,m))
			{
				minnum=Math.min(minnum, r);
			}
			break;
			}
			if(ispossible(mid,n,m))
			{
				minnum=mid;
				r=mid-1;
			}
			else
			{
				l=mid+1;
			}
			
		}
		return minnum;
	}
	public static boolean ispossible(long x,long n,long m)
	{
		long m1=x/2;
		long m2=x/3;
		long m3=x/6;
		m1-=m3;
		m2-=m3;
		if(m1<n)
		{
			long temp=Math.min(n-m1, m3);
			m3-=temp;
			m1+=temp;
			
		}
		if(m2<m)
		{
			long temp=Math.min(m-m2,m3 );
			m3-=temp;
			m2+=temp;
		}
		if(m1>=n && m2>=m)
		{
			return true;
		}
		return false;
	}
	
	
	
	
	
	
	
	
	 static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar;
		private int snumChars;
		private SpaceCharFilter filter;

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

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

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			int res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}
		
		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}
		
		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		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);
		}
	}

}
