#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long a, b;
  cin >> a >> b;
  long long six = min(a / 3, b / 2);
  long long counted_six = 0;
  a *= 2, b *= 3;
  long long x = a, y = b;
  while (six != 0) {
    for (long long i = 0; i < six; i++) {
      if (x <= y) {
        x += 2;
      } else {
        y += 3;
      }
    }
    counted_six += six;
    six = min(x / 6, y / 6) - counted_six;
  }
  cout << max(x, y);
}
