#include <bits/stdc++.h>
using namespace std;
long long MAXN = 1e6 + 10;
long long a, b, k, c1[10000000];
long long c[10000000];
long long i = 0;
int main() {
  c[0] = 0;
  c1[0] = 0;
  c[1] = 2;
  c1[1] = 3;
  cin >> a >> b;
  while ((i / 2 < a) || (i / 3 < b) || (i / 2 + i / 3 - i / 6) < (a + b)) i++;
  cout << i << endl;
  cin >> i;
}
