#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int asd(T &ret) {
  char r;
  bool start = false, neg = false;
  ret = 0;
  bool isaNumber = false;
  while (true) {
    r = getchar();
    if (r == EOF) {
      return 0;
    }
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && !start) {
      continue;
    }
    if ((r - '0' < 0 || r - '0' > 9) && r != '-' && start) {
      break;
    }
    if (start) ret *= 10;
    start = true;
    if (r == '-')
      neg = true;
    else
      ret += r - '0';
  }
  if (neg) ret *= -1;
  return 1;
}
template <class T>
inline int asd(T &ret1, T &ret2) {
  asd(ret1);
  asd(ret2);
  return 2;
}
template <class T>
inline int asd(T &ret1, T &ret2, T &ret3) {
  asd(ret1, ret2);
  asd(ret3);
  return 3;
}
template <class T>
inline int asd(T &ret1, T &ret2, T &ret3, T &ret4) {
  asd(ret1, ret2);
  asd(ret3, ret4);
  return 4;
}
template <class T>
inline void asdasd(T x, char endWith) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  char buf[21], *p = buf;
  do {
    *p++ = '0' + x % 10;
    x /= 10;
  } while (x);
  do {
    putchar(*--p);
  } while (p > buf);
  putchar(endWith);
}
template <class T>
inline void asdasd(T x1, T x2, char separateBy, char endWith) {
  asdasd(x1, separateBy);
  asdasd(x2, endWith);
}
template <class T>
inline void asdasd(T x1, T x2, T x3, char separateBy, char endWith) {
  asdasd(x1, x2, separateBy, separateBy);
  asdasd(x3, endWith);
}
template <class T>
inline void asdasd(T x1, T x2, T x3, T x4, char separateBy, char endWith) {
  asdasd(x1, x2, x3, separateBy, separateBy);
  asdasd(x4, endWith);
}
int two_needed, three_needed;
bool Pass(int n) {
  long long int only_two = (n / 2 - n / 6);
  long long int only_three = (n / 3 - n / 6);
  long long int common = n / 6;
  long long int need = 0;
  if (only_two < two_needed) need += (two_needed - only_two);
  if (only_three < three_needed) need += (three_needed - only_three);
  return need <= common;
}
int main() {
  cin >> two_needed >> three_needed;
  long long low = 0, high = 1LL << 31;
  while (high - low > 1) {
    long long int mid = (low + high) >> 1;
    if (Pass(mid)) {
      high = mid;
    } else
      low = mid;
  }
  for (long long int i = max(low - 2, 1LL); i < high + 2; i++) {
    if (Pass(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
