#include <bits/stdc++.h>
using namespace std;
template <class T>
void in(T &x) {
  x = 0;
  bool flag = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
int n, m;
inline bool check(int x) {
  int num2 = x / 2, num3 = x / 3, num6 = x / 6;
  if (num2 < n) return false;
  if (num3 < m) return false;
  if (num2 + num3 - num6 < n + m) return false;
  return true;
}
int main() {
  in(n), in(m);
  int l = 0, r = 2e9, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
