#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  if (n % 2 == 0) {
    if (k > (n / 2))
      cout << (n - ((n - k) * 2)) << endl;
    else if (k <= (n / 2))
      cout << (((k - 1) * 2) + 1) << endl;
  } else if (n % 2 != 0) {
    if (k <= ((n / 2) + 1))
      cout << (((k - 1) * 2) + 1) << endl;
    else if (k > ((n / 2) + 1))
      cout << (n - 1) - ((n - k) * 2) << endl;
  }
}
