#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> g;
vector<long long> h;
long long ans, s;
map<long long, long long> t;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  g.push_back(0);
  h.push_back(0);
  long long r = 0, t = 0;
  for (long long i = 3; i; i += 6) {
    if (r == m) {
      break;
    }
    g.push_back(i);
    r++;
    if (r == m) {
      break;
    }
  }
  for (long long i = 2; i; i += 2) {
    if (t == n) {
      break;
    }
    if (i % 3 == 0) {
      continue;
    }
    h.push_back(i);
    t++;
    if (t == n) {
      break;
    }
  }
  for (long long i = 6; i < max(g[g.size() - 1], h[h.size() - 1]); i += 6) {
    if (g[g.size() - 1] > h[h.size() - 1]) {
      g.pop_back();
      s = i;
    } else {
      h.pop_back();
      s = i;
    }
  }
  cout << max(max(g[g.size() - 1], h[h.size() - 1]), s) << endl;
}
