#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, m, l1, l2, l;
int main(void) {
  while (cin >> n >> m) {
    l1 = 2 * n;
    l2 = 3 * m;
    for (long long i = 6; i <= min(l1, l2); i += 6) {
      if (l1 <= l2)
        l1 += 2;
      else
        l2 += 3;
    }
    cout << max(l1, l2) << endl;
  }
  return 0;
}
