#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0, sum = n + m;
  int i = 0, j = 0, k;
  for (k = 1; ans < sum; k++) {
    if (k % 6 == 0) {
      if (n * 2 > m * 3 && i < n)
        m++, ans++, i++, j++;
      else if (n * 2 <= m * 3 && j < m)
        n++, ans++, j++, i++;
    } else if (k % 2 == 0 && i < n) {
      ans++, i++;
    } else if (k % 3 == 0 && j < m) {
      ans++, j++;
    }
  }
  cout << k - 1 << endl;
  return 0;
}
