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