#include <bits/stdc++.h>
using namespace std;
int n, m;
bool check(int x) {
  if ((x / 2) >= n && (x / 3) >= m && ((x / 2) + (x / 3) - (x / 6)) >= (n + m))
    return 1;
  else
    return 0;
}
int main() {
  cin >> n >> m;
  int l = 0, r = 10000000;
  while (l < r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}
