#include <bits/stdc++.h>
using namespace std;
long long n, x;
inline void file() {
  freopen("agc001_B.in", "r", stdin);
  freopen("agc001_B.out", "w", stdout);
}
int main() {
  scanf("%lld%lld", &n, &x);
  printf("%lld", (!(n & 1) && x == n / 2) ? x * 3 : (n - 1) * 3);
  return 0;
}
