#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n <= m)
    cout << 3 * m;
  else if (n >= 3 * m)
    cout << 2 * n;
  else {
    int res = ((n + m) / 4) * 6;
    int left = (n + m) % 4;
    if (left == 1) res += 2;
    if (left == 2) res += 3;
    if (left == 3) res += 4;
    cout << res;
  }
}
