#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using vc = vector<T>;
ll p[3];
function<ll(ll)> h[3] = {
    [](ll i) {
      if (i == 0) return 0LL;
      return 6 * ((i - 1) / 2) + (i % 2 == 1 ? 2 : 4);
    },
    [](ll i) {
      if (i == 0) return 0LL;
      return 6 * i - 3;
    },
    [](ll i) { return 6 * i; },
};
int main() {
  scanf("%lld %lld", &p[0], &p[1]);
  p[2] = 0;
  while (true) {
    ll f = (h[1](p[1]) > h[0](p[0]));
    if (h[2](p[2] + 1) < h[f](p[f])) {
      p[2]++, p[f]--;
    } else {
      break;
    }
  }
  printf("%lld\n", max({h[0](p[0]), h[1](p[1]), h[2](p[2])}));
  return 0;
}
