#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *, long long *);
int main() {
  long long int n, k, evlist, oddlist;
  scanf("%I64d%I64d", &n, &k);
  if ((n - 1) % 2)
    evlist = oddlist = n / 2;
  else {
    oddlist = (n / 2) + 1;
    evlist = n / 2;
  }
  if (k <= oddlist) {
    k = 1 + (2 * (k - 1));
  } else if (k <= evlist + oddlist) {
    k -= oddlist;
    k = 2 + (2 * (k - 1));
  } else {
    k = n;
  }
  printf("%I64d", k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     117a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    %rax,-0x20(%rbp)
jmp    11a2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jg     11c9 <main+0xa9>
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
shl    $0x1,%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1213 <main+0xf3>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    -0x28(%rbp),%rcx
cmp    %rcx,%rax
jg     1206 <main+0xe6>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
shl    $0x1,%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    120e <main+0xee>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1213 <main+0xf3>
mov    -0x18(%rbp),%rsi
lea    0xde7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x10(%rsp),%rsi
mov    %esi,%eax
and    $0x1,%eax
mov    %rsi,%rdx
shr    $0x3f,%rdx
add    %rsi,%rdx
sar    %rdx
add    %rdx,%rax
mov    0x8(%rsp),%rcx
cmp    %rax,%rcx
jle    1176 <main+0x56>
add    %rax,%rdx
cmp    %rdx,%rcx
jg     117e <main+0x5e>
not    %rax
add    %rax,%rcx
lea    (%rcx,%rcx,1),%rsi
add    $0x2,%rsi
jmp    117e <main+0x5e>
lea    (%rcx,%rcx,1),%rsi
add    $0xffffffffffffffff,%rsi
mov    %rsi,0x8(%rsp)
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%I64d%I64d\00"
@.str.1 = [6 x i8] c"%I64d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
%7 = load i64, i64* %2
%8 = sub nsw i64 %7, 1
%9 = srem i64 %8, 2
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i64, i64* %2
%13 = sdiv i64 %12, 2
store i64 %13, i64* %5
store i64 %13, i64* %4
br label %20
14: ; preds = %0
%15 = load i64, i64* %2
%16 = sdiv i64 %15, 2
%17 = add nsw i64 %16, 1
store i64 %17, i64* %5
%18 = load i64, i64* %2
%19 = sdiv i64 %18, 2
store i64 %19, i64* %4
br label %20
20: ; preds = %14, %11
%21 = load i64, i64* %3
%22 = load i64, i64* %5
%23 = icmp sle i64 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i64, i64* %3
%26 = sub nsw i64 %25, 1
%27 = mul nsw i64 2, %26
%28 = add nsw i64 1, %27
store i64 %28, i64* %3
br label %46
29: ; preds = %20
%30 = load i64, i64* %3
%31 = load i64, i64* %4
%32 = load i64, i64* %5
%33 = add nsw i64 %31, %32
%34 = icmp sle i64 %30, %33
br i1 %34, label %35, label %43
35: ; preds = %29
%36 = load i64, i64* %5
%37 = load i64, i64* %3
%38 = sub nsw i64 %37, %36
store i64 %38, i64* %3
%39 = load i64, i64* %3
%40 = sub nsw i64 %39, 1
%41 = mul nsw i64 2, %40
%42 = add nsw i64 2, %41
store i64 %42, i64* %3
br label %45
43: ; preds = %29
%44 = load i64, i64* %2
store i64 %44, i64* %3
br label %45
45: ; preds = %43, %35
br label %46
46: ; preds = %45, %24
%47 = load i64, i64* %3
%48 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%I64d%I64d\00"
@.str.1 = [6 x i8] c"%I64d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = bitcast i64* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%6 = load i64, i64* %1
%7 = and i64 %6, 1
%8 = sdiv i64 %6, 2
%9 = add nsw i64 %8, %7
%10 = load i64, i64* %2
%11 = icmp sgt i64 %10, %9
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = shl i64 %10, 1
%14 = add i64 %13, -1
store i64 %14, i64* %2
br label %24
15: ; preds = %0
%16 = add nsw i64 %9, %8
%17 = icmp sgt i64 %10, %16
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = xor i64 %9, -1
%20 = add i64 %10, %19
%21 = shl nsw i64 %20, 1
%22 = add nsw i64 %21, 2
store i64 %22, i64* %2
br label %24
23: ; preds = %15
store i64 %6, i64* %2
br label %24
24: ; preds = %18, %23, %12
%25 = phi i64 [ %22, %18 ], [ %6, %23 ], [ %14, %12 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %25)
ret i32 0
}