#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    int l = 0, r = 3000000;
    while (l < r) {
      int mid = l + (r - l) / 2;
      int t1 = mid / 2 - mid / 6;
      int t2 = mid / 3 - mid / 6;
      int t3 = mid / 6;
      if (t3 >= max(0, n - t1) + max(0, m - t2))
        r = mid;
      else
        l = mid + 1;
    }
    printf("%d\n", l);
  }
  return 0;
}
