#include <bits/stdc++.h>
using namespace std;
long long n, a, b, l, r, mid, hasil, jum, banyak2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  l = max(2 * a, 3 * b);
  r = 1e18;
  while (l <= r) {
    jum = 0;
    mid = (l + r) / 2;
    hasil = (mid - 3) / 6 + 1;
    banyak2 = mid / 2;
    if (hasil < b) {
      jum = b - hasil;
    }
    if (mid / 6 < jum || banyak2 - jum < a) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << l << '\n';
}
