#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, int p) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    long long kek = pow(a, p / 2);
    return kek * kek;
  }
  return pow(a, p - 1) * a;
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << 2 * n;
    return 0;
  }
  if (n == 0) {
    cout << 3 * m;
    return 0;
  }
  int a = n * 2, b = m * 3;
  int k = min(n / 3, m / 2);
  while (k > 0) {
    if (a + 2 < b + 3) {
      k--, a += 2;
      if (a % 6 == 0 && a <= b) k++;
    } else {
      k--, b += 3;
      if (b % 6 == 0 && b <= a) k++;
    }
  }
  cout << max(a, b);
  return 0;
}
