#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const double INF = 1e9;
int main() {
  long long N, X;
  cin >> N >> X;
  if (X * 2LL != N)
    cout << (N - 1LL) * 3LL << endl;
  else
    cout << X * 3LL << endl;
  return 0;
}
