#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int p = 0, q = 2 * n + 3 * m;
  while (p < q) {
    int r = (p + q) / 2;
    if (max(0, n - (r / 2 - r / 6)) + max(0, m - (r / 3 - r / 6)) <= r / 6) {
      q = r;
    } else {
      p = r + 1;
    }
  }
  cout << p;
}
