#include <bits/stdc++.h>
using namespace std;
int i, m, n;
int a[100005];
bool judge(int x) {
  if (x < 2 * m || x < 3 * n || (x / 2 + x / 3 - x / 6) < m + n)
    return false;
  else
    return true;
}
int main() {
  cin >> m >> n;
  int l = 0;
  int r = 10000000;
  while (l < r) {
    int mid = (l + r) / 2;
    if (judge(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << r << endl;
}
