#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 */
typedef int /*<<< orphan*/ input;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
char *str_trim(char *);
int main() {
  int total, which;
  char input[128];
  char *tmp = NULL;
  fgets(input, sizeof(input), stdin);
  tmp = str_trim(input);
  sscanf(tmp, "%d %d", &total, &which);
  if (which % 2 == 0) {
    printf("%d\n", (total + 1 - which) / 2 + 1);
  } else {
    printf("%d\n", which / 2 + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
mov    0x2e7d(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    -0x90(%rbp),%rdi
call   1060 <str_trim@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1050 <sscanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11e0 <main+0xa0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x1,%esi
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
jmp    11fc <main+0xbc>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0x1,%esi
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x90,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1060 <str_trim@plt>
lea    0xe8e(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
call   1050 <sscanf@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
sub    %eax,%ecx
add    $0x1,%ecx
test   $0x1,%al
cmovne %eax,%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
add    $0x1,%esi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca i8*
store i32 0, i32* %1
store i8* null, i8** %5
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 128, i32 %7)
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = call i8* @str_trim(i8* %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %3
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %0
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %3
%20 = sub nsw i32 %18, %19
%21 = sdiv i32 %20, 2
%22 = add nsw i32 %21, 1
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %29
24: ; preds = %0
%25 = load i32, i32* %3
%26 = sdiv i32 %25, 2
%27 = add nsw i32 %26, 1
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %24, %16
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 128, i32 %7)
%9 = call i8* @str_trim(i8* %6)
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %2
%12 = and i32 %11, 1
%13 = icmp eq i32 %12, 0
%14 = load i32, i32* %1
%15 = sub i32 1, %11
%16 = add i32 %15, %14
%17 = select i1 %13, i32 %16, i32 %11
%18 = sdiv i32 %17, 2
%19 = add nsw i32 %18, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
ret i32 0
}