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