#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ans = 0, p2 = 0, p3 = 0, p6 = 0;
  while (1) {
    if (max(n - p2, 0) + max(m - p3, 0) <= p6) break;
    ans++;
    if (ans % 6 == 0)
      p6++;
    else if (ans % 2 == 0)
      p2++;
    else if (ans % 3 == 0)
      p3++;
  }
  printf("%d\n", ans);
  return 0;
}
