#include <bits/stdc++.h>
using namespace std;
long long a, b;
bool can(long long x) {
  long long both = x / 6;
  long long two = x / 2;
  long long three = x / 3;
  two -= both;
  three -= both;
  long long need_2 = max(a - two, 0LL);
  long long need_3 = max(b - three, 0LL);
  if (both >= need_2 + need_3) return true;
  return false;
}
int main() {
  cin >> a >> b;
  long long low = 0;
  long long high = 1e18;
  while (high - low > 1) {
    long long mid = (low + high) / 2;
    if (can(mid))
      high = mid;
    else
      low = mid;
  }
  cout << high;
  return 0;
}
