#include <bits/stdc++.h>
using namespace std;
int n, m;
bool ok(int mid) {
  int num1 = mid / 2, num2 = mid / 3, num3 = mid / 6;
  if (num1 < n || num2 < m || num1 + num2 - num3 < n + m) return false;
  return true;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    int l = 0, r = 1000000000;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      if (ok(mid))
        r = mid;
      else
        l = mid;
    }
    printf("%d\n", r);
  }
  return 0;
}
