#include <bits/stdc++.h>
using namespace std;
int n, m, maxn, maxm, s = 0, tosolve;
int main() {
  scanf("%d%d", &n, &m);
  maxn = n * 2;
  maxm = m * 3;
  tosolve = min(maxm / 6 - s, maxn / 6 - s);
  while (tosolve > 0) {
    if (maxm + 3 <= maxn + 2) {
      s++;
      maxm += 3;
    } else {
      s++;
      maxn += 2;
    }
    tosolve = min(maxn / 6 - s, maxm / 6 - s);
  }
  printf("%d\n", max(maxm, maxn));
  return 0;
}
