#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  long long x, y;
  cin >> x >> y;
  long long n = 1;
  n = max(2 * x, 3 * y);
  while (x + y > n / 2 + n / 3 - n / 6) {
    n++;
  }
  cout << n << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
