#include <bits/stdc++.h>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
bool f(int a, int b, int no){
// cout<<no<<endl;
int x, y;
int six = no/6;
int cut = min(2*a, 3*b)/6;
x = no/2;
y = no/3;
int x2 = x-six;
int x3 = y-six;
x2 = a-x2;
x3 = b-x3;
if(x2<=0 && x3<=0)
return true;
if(x2+x3<=six)
return true;
return false;
}
int main() {
int a, b, i;
cin >> a >>b;
int x, y;
x = 2*a, y = 3*b;
i=max(x, y);
while( f(a, b, i) == false ){
i++;
while(i%2 !=0 && i%3 !=0)
i++;
}
cout<<i<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZ2MgZ2V0Y2hhcl91bmxvY2tlZAojZGVmaW5lIGZvKGksbikgZm9yKGk9MDtpPG47aSsrKQojZGVmaW5lIEZvKGksayxuKSBmb3IoaT1rO2k8bjtpKyspCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgcGlpIHBhaXI8aW50LGludD4KI2RlZmluZSB2aSB2ZWN0b3I8aW50PgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIEYgZmlyc3QKI2RlZmluZSBTIHNlY29uZAp1c2luZyBuYW1lc3BhY2Ugc3RkOwpib29sIGYoaW50IGEsIGludCBiLCBpbnQgbm8pewoJLy8gY291dDw8bm88PGVuZGw7CglpbnQgeCwgeTsKCWludCBzaXggPSBuby82OwoJaW50IGN1dCA9IG1pbigyKmEsIDMqYikvNjsKCXggPSBuby8yOyAKCXkgPSBuby8zOwoJaW50IHgyID0geC1zaXg7CglpbnQgeDMgPSB5LXNpeDsKCXgyID0gYS14MjsKCXgzID0gYi14MzsKCWlmKHgyPD0wICYmIHgzPD0wKQoJCXJldHVybiB0cnVlOwoJaWYoeDIreDM8PXNpeCkKCQlyZXR1cm4gdHJ1ZTsKCXJldHVybiBmYWxzZTsKCQp9CmludCBtYWluKCkgewoJaW50IGEsIGIsIGk7CgljaW4gPj4gYSA+PmI7CglpbnQgeCwgeTsKCXggPSAyKmEsIHkgPSAzKmI7CglpPW1heCh4LCB5KTsKCXdoaWxlKCBmKGEsIGIsIGkpID09IGZhbHNlICl7CgkJaSsrOwoJCXdoaWxlKGklMiAhPTAgJiYgaSUzICE9MCkKCQkJaSsrOwoJfQoJY291dDw8aTw8ZW5kbDsKCXJldHVybiAwOwp9