#include <bits/stdc++.h>
const int mod = 1000000007;
const long long INF = 9000000000000000000;
using namespace std;
bool isValid(long long mid, long long c1, long long c2) {
  long long a = mid / 2;
  long long b = mid / 3;
  long long c = mid / 6;
  if (a < c1 || b < c2) return false;
  if (a + b - c >= c1 + c2) return true;
  return false;
}
void solve() {
  long long c1, c2, ans;
  cin >> c1 >> c2;
  long long lb = 2, ub = 3000000;
  while (lb <= ub) {
    long long mid = (lb + ub) / 2;
    if (isValid(mid, c1, c2)) {
      ans = mid;
      ub = mid - 1;
    } else
      lb = mid + 1;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
