#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
ll n, m;
cin >> n >> m;
ll maxN = 2 * n;
ll maxM = 3 * m;
for (int i = 2; i <= min(maxN, maxM); i += 2)
{
if (i % 3 == 0)
{
if (maxN <= maxM) maxN += 2;
else maxM += 3;
}
}
ll maxTower = max(maxN, maxM);
cout << maxTower;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGxsOwoKaW50IG1haW4oKQp7CglsbCBuLCBtOwoJY2luID4+IG4gPj4gbTsKCglsbCBtYXhOID0gMiAqIG47CglsbCBtYXhNID0gMyAqIG07CgoJZm9yIChpbnQgaSA9IDI7IGkgPD0gbWluKG1heE4sIG1heE0pOyBpICs9IDIpCgl7CgkJaWYgKGkgJSAzID09IDApCgkJewoJCQlpZiAobWF4TiA8PSBtYXhNKSBtYXhOICs9IDI7CgkJCWVsc2UgbWF4TSArPSAzOwoJCX0KCX0KCglsbCBtYXhUb3dlciA9IG1heChtYXhOLCBtYXhNKTsKCWNvdXQgPDwgbWF4VG93ZXI7Cn0=