#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;
  scanf("%lld %lld", &n, &k);
  long long int ans = 0;
  if (n % 2 == 0) {
    if (k <= (n / 2)) {
      ans = 2 * k - 1;
    } else {
      long long int i = k - (n / 2);
      ans = 2 * i;
    }
  } else {
    if (k <= ((n / 2) + 1)) {
      ans = 2 * k - 1;
    } else {
      long long int i = k - (n + 1) / 2;
      ans = 2 * i;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <scanf@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11d3 <main+0xb3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jg     119e <main+0x7e>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11ce <main+0xae>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    124b <main+0x12b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    $0x1,%rcx
cmp    %rcx,%rax
jg     1212 <main+0xf2>
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1246 <main+0x126>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    124b <main+0x12b>
mov    -0x20(%rbp),%rsi
lea    0xdb4(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%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),%rcx
mov    0x8(%rsp),%rax
mov    %rcx,%rdx
shr    $0x3f,%rdx
add    %rcx,%rdx
sar    %rdx
test   $0x1,%cl
jne    1163 <main+0x43>
mov    %rax,%rsi
sub    %rdx,%rsi
jle    1189 <main+0x69>
add    %rsi,%rsi
jmp    1191 <main+0x71>
add    $0x1,%rdx
cmp    %rdx,%rax
jle    1189 <main+0x69>
lea    0x1(%rcx),%rdx
shr    $0x3f,%rdx
add    %rdx,%rcx
add    $0x1,%rcx
shr    %rcx
sub    %rcx,%rax
add    %rax,%rax
mov    %rax,%rsi
jmp    1191 <main+0x71>
lea    (%rax,%rax,1),%rsi
add    $0xffffffffffffffff,%rsi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"%lld %lld\00"
@.str.1 = [6 x i8] c"%lld\0A\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 ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%6 = load i64, i64* %1
%7 = and i64 %6, 1
%8 = icmp eq i64 %7, 0
%9 = load i64, i64* %2
%10 = sdiv i64 %6, 2
br i1 %8, label %11, label %19
11: ; preds = %0
%12 = icmp sgt i64 %9, %10
br i1 %12, label %16, label %13
13: ; preds = %11
%14 = shl nsw i64 %9, 1
%15 = add nsw i64 %14, -1
br label %30
16: ; preds = %11
%17 = sub nsw i64 %9, %10
%18 = shl nsw i64 %17, 1
br label %30
19: ; preds = %0
%20 = add nsw i64 %10, 1
%21 = icmp sgt i64 %9, %20
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = shl nsw i64 %9, 1
%24 = add nsw i64 %23, -1
br label %30
25: ; preds = %19
%26 = add nsw i64 %6, 1
%27 = sdiv i64 %26, -2
%28 = add i64 %9, %27
%29 = shl nsw i64 %28, 1
br label %30
30: ; preds = %22, %25, %13, %16
%31 = phi i64 [ %15, %13 ], [ %18, %16 ], [ %24, %22 ], [ %29, %25 ]
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %31)
ret i32 0
}