#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 4;
int main() {
  int n, m;
  cin >> n >> m;
  int l = 0, r = (int)1e9;
  for (; r > l;) {
    int k = (l + r) / 2;
    if (k / 2 >= n && k / 3 >= m && k / 2 + k / 3 - k / 6 >= n + m) {
      r = k;
    } else {
      l = k + 1;
    }
  }
  cout << l;
  return 0;
}
