#include <bits/stdc++.h>
int main() {
  int n, m;
  int k, s(0), e(1 << 30);
  std::scanf("%d%d", &n, &m);
  while (s + 1 < e) {
    k = (s + e) / 2;
    if (n <= k / 2 && m <= k / 3 && n + m <= k / 2 + k / 3 - k / 6)
      e = k;
    else
      s = k;
  }
  std::printf("%d\n", e);
  return 0;
}
