#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  if (n > 2 * x) {
    cout << 2 * n + x << endl;
  } else if (n == 2 * x) {
    cout << 3 * x << endl;
  } else {
    cout << 2 * n << endl;
  }
  return 0;
}
