#include <bits/stdc++.h>
int main() {
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  long long int i = 0, res = 0;
  if ((n % 2 != 0 && k <= (n / 2 + 1)) || (n % 2 == 0 && k <= n / 2)) {
    res = 1;
    for (i = 0; i < k - 1; i++) res = res + 2;
  } else {
    if (n % 2 == 0)
      k = -(n / 2 - k);
    else
      k = k - n / 2 - 1;
    res = 0;
    for (i = 0; i < k; i++) res = res + 2;
  }
  printf("%lld", res);
}
