#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  if (X == N / 2.0)
    cout << 3 * X << endl;
  else if (X > N / 2.0)
    cout << 3 * X << endl;
  else
    cout << 6 * X << endl;
}
