#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    int n, m, ch = 1;
    scanf("%d%d", &n, &m);
    long long nw, mw, mn, mh, s, t, x = 0;
    nw = 1ll * 2 * n;
    mw = 1ll * 3 * m;
    mh = max(nw, mw);
    while (x <= nw && x <= mw) {
      x += 6;
      if (x <= nw && x <= mw) {
        if (nw <= mw)
          nw += 2;
        else
          mw += 3;
        mh = max(nw, mw);
      }
    }
    cout << mh;
  }
  return 0;
}
