#include <bits/stdc++.h>
using namespace std;
bool done[600001];
int main() {
  memset(done, false, sizeof done);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= 5000000; ++i) {
    int x = i / 2 + i / 3 - i / 6;
    if (x >= (n + m) && (i / 2) >= n && (i / 3) >= m &&
        (i % 2 == 0 || i % 3 == 0)) {
      cout << i << "\n";
      return 0;
    }
  }
}
