#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 1e9, k;
int main() {
  scanf("%d%d", &n, &m);
  k = min(n / 3, m / 2);
  for (int i = 1; i <= 1000 * 1000 * 100; ++i) {
    if (i / 2 >= n && i / 3 >= m && i / 2 + i / 3 - i / 6 >= n + m) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
