#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
int n, m;
bool check(int x) {
  int a2 = x / 2, a3 = x / 3, a6 = x / 6;
  a2 -= a6;
  a3 -= a6;
  if (max(n - a2, 0) + max(m - a3, 0) <= a6)
    return true;
  else
    return false;
}
int main() {
  cin >> n >> m;
  int l = 1, r = 1e7;
  int ans = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
