#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long start = 0, end = 6 * (n + m);
  while (start <= end) {
    long long mid = (start + end) / 2;
    long long val1 = (mid / 2) - (mid / 6);
    long long val2 = (mid / 3) - (mid / 6);
    if ((mid / 6) >= (max(n - val1, 0LL) + max(m - val2, 0LL))) {
      end = mid - 1;
    } else {
      start = mid + 1;
    }
  }
  cout << start << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) solve();
}
