peterverebics/CodeNet_Python_118 huggingface dataset:
import math
import sys
import bisect
readline = sys.stdin.readline


def main():
    n, a, b = map(int, readline().rstrip().split())
    if (b - a) % 2 == 0:
        print((b - a) // 2)
        return
    print(min(a-1, n-b) + (b - a + 1)//2)


if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())
dif = abs(A - B)
ans = 0

if dif % 2 == 0:
    ans = dif // 2
else:
    ans = min(A - 1, N - B) + 1 + dif // 2
print(ans)
n, a, b = map(int, input().split())
d = (b-a)//2
if (b-a) % 2:
  print(d + min(a, n-b+1))
else:
  print(d)
import sys
def input(): return sys.stdin.readline().strip()
def MAP(): return map(int, input().split())

n, a, b = MAP()
print(abs(a - b) // 2 if not (a - b) % 2 else abs(a - b) // 2 + min(min(a, b) - 1, n - max(a, b)) + 1)
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)
n, a, b = map(int, input().split())
a = min(a, b)
b = max(a, b)

ret = 0
if (b - a) & 1:
    if n - a < b - 1:
        ret = n - b + 1
        a += ret
        b = n
    else:
        ret = a
        a = 1
        b -= ret
print(ret + (b - a) // 2)
# coding: utf-8


def main():
    N, A, B = map(int, input().split())

    ans = (B - A) // 2 if (B - A) % 2 == 0 else min(A - 1, N - B) + 1 + (B - A - 1) // 2

    print(ans)

if __name__ == "__main__":
    main()
#A - Table Tennis Training
N,A,B = map(int,input().split())
if abs(A-B)%2 == 0:
    ans = abs(A-B)//2
else:
    a = min(A-1,N-B)
    ans = a + 1 + (B-A-1)//2
print(ans)
def TableTennis():
    N, A, B = map(int, input().split())
    ans = 0
    if (A - B) % 2 == 0:
        ans = abs(A - B) // 2
    else:
        len_1 = A - 1
        len_2 = N - B
        ans = min(len_1, len_2) + 1 + ((abs(A - B) - 1) // 2)
    print(ans)

TableTennis()
N,A,B = map(int,input().split())
if (B-A) % 2 == 0:
  print((B-A)//2)
else:
  print(min(A-1,N-B)+1+(B-A-1)//2)
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  print(min(a, n-b+1) + (b-a-1) // 2)
n,a,b = map(int,input().split())
if abs(b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min((2*n-a-b+1)//2,(a+b-1)//2))
n,a,b = map(int,input().split())

if a < b:
  a,b = b,a

if (a - b) %2 == 0:
  print((a-b)//2)
else:
    print(min(a-1,n-b)+1+(b-a)//2)
# AGC041A - Table Tennis Training
def main():
    N, A, B = map(int, input().split())
    if A % 2 == B % 2:
        ans = (B - A) // 2
    else:
        ans = min(A - 1, N - B) + 1 + (B - A - 1) // 2
    print(ans)


if __name__ == "__main__":
    main()
n, a, b = map(int, input().split())

if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    print(min((a - 1) + 1, (n - b) + 1) + abs(b - a - 1) // 2)
N,A,B=map(int,input().split())

if abs(A-B) % 2 == 0:
  print(abs(A-B) // 2)
  exit()
  
if abs(A-B) == 1:
  print(min(max(A-1,B-1),max(N-A,N-B)))
  exit()
  
print(min(min(A-1,B-1),min(N-A,N-B))+1+(abs(A-B)-1)//2)
n,a,b = map(int,input().split())
if (b - a)%2 == 0:
    x = (b - a)//2
    y = min(max(a-1,b-1),max(n-a,n-b))
    print(min(x,y))
else:
    p = max(a-1,b-1)
    q = max(n-a,n-b)
    r = a-1+1+(b-(a-1)-1-1)//2
    s = n-b+1+(n-(n-b+1)-a)//2
    #print(p,q,r,s)
    print(min(p,q,r,s))
N,A,B = [int(x) for x in input().split()]
if abs(A-B)%2==0:
  print(abs(A-B)//2)
  exit()
a = A-1
b = N-B
c = min(a,b)
print((B-A+1)//2+c)
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:print((B - A)//2)
else:
    print(min(N-B+1+(N-(A+N-B+1))//2, A-1+1+(B-A)//2))
N, A, B = map(int, input().split())

if abs(A-B) % 2 == 0:
    print(abs(A-B)//2)
else:
    M = max(A, B)
    m = min(A, B)
    print(min(N-m, M-1, (N-M+1)+(M-m)//2, m+(M-m)//2))
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print ((B-A)//2)
else:
  print (min(A+B-2,2*N-A-B)//2+1)
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
	print((b - a) // 2)
elif (b - a) % 2 == 1:
	na = n - a
	nb = n - b
	a1 = a - 1
	b1 = b - 1
	if na + nb <= a1 + b1:
		print((na + nb + 1) // 2)
	else:
		print((a1 + b1 + 1) // 2)
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    if A-1<=N-B:
        ans=A+(B-A)//2
    else:
        ans=N-B+1+(B-A)//2
    print(ans)
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,A,B=map(int,pin().split())
  if (B-A)%2==0:
    print((B-A)//2)
    return 
  if A<N-B+1:
    print(A+(B-A-1)//2)
  else:
    print(N-B+1+(B-A-1)//2)
  return 
main()
N, A, B = map(int, input().split())
if abs(A - B) % 2 == 0:
    ans = (abs(A - B)) // 2
else:
    ans = min(A - 1, N - B) + 1 + (abs(A - B) - 1) // 2
print(ans)
def main():
    n, a, b = map(int, input().split()) 

    ab_diff = abs(a-b)
    if ab_diff%2 == 0:
        print(ab_diff//2)
        return
    
    a_edge_diff = min(abs(a-1),abs(n-a))
    b_edge_diff = min(abs(b-1),abs(n-b))
    # near_diff = min(a_edge_diff, b_edge_diff)
    if a_edge_diff <= b_edge_diff:
        print(a_edge_diff+1+ (ab_diff-1)//2)
    else:
        print(b_edge_diff+1+ (ab_diff-1)//2)

if __name__ == "__main__":
    main()
N, A, B = map(int, input().split())

ans = 0

def odd():
    global ans
    ans += (B - A) // 2

if (B - A) % 2 == 0:
    odd()
else:
    if (N - B) <= (A - 1):
        ans += (N - B) + 1
        A += (N - B) + 1
        B = N
    else:
        ans += (A - 1) + 1
        B -= (A - 1) + 1
        A = 1
    odd()

print(ans)
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  #A->1.1, B->B-A
  a = A + (B-A-1)//2
  #A->A+N-B+1, B->N.N
  b = N-B+1 + (- A + B - 1)//2
  
  print(min(a,b))
n, a, b = [int(x) for x in input().split()]
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    print(min(a, n - b + 1) + (b - a - 1) // 2)
n, a, b = list(map(int, input().split()))

if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    print(min((2*n-a-b+1)//2, (a+b-1)//2))
from itertools import groupby


def all_equal(iterable):
    g = groupby(iterable)
    return next(g, True) and not next(g, False)


N, A, B = map(int, input().split())
if all_equal(map(lambda x: x % 2, (A, B))):
    print((B - A) // 2)
else:
    print(min((A - 1, N - B)) + 1 + (B - A - 1) // 2)
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    if a-1<=n-b:
        tmp=a
        b=b-a
        print(((b-1)//2)+a)
    else:
        tmp=(n-b)+1
        a=a+tmp
        print(((n-a)//2)+tmp)
N,A,B = map(int, input().split())
if (B-A)%2 == 0:
    print((B-A)//2)
else:
    print(min(A,N-B+1)+(B-A)//2)
n, a, b = map(int, input().split())
if abs(a-b)%2 == 0:
    print(abs(a-b)//2)
else:
    print(min(a-1, n-b) + 1 + (b-a-1)//2)
def main():
    N, A, B = list(map(int, input().split()))
    if (A ^ B) & 1:
        return min((A - 1) + 1 + (B - A - 1) // 2,
                   (N - B) + 1 + (N - (A + N - B + 1)) // 2)
    return (B - A) // 2

print(main())
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+1+(b-a)//2)
N, A, B = map(int, input().split(" "))

if A % 2 == B % 2:
    print((B - A) // 2)
else:
    print(min(N - B, A - 1) + 1 + (B - A - 1) // 2)
n, a, b = map(int,input().split())
 
if (a+b)%2 == 0:
	print((b-a)//2)
else:
	print(min(a-1,n-b)+1+(b-a)//2)
n,a,b=map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  ans=min(a-1,n-b)+1+(b-a-1)//2
  print(ans)
n,a,b = map(int, input().split())
diff = abs(a-b)
if diff%2 == 0:
    print(diff//2)
else:
    near = min(abs(a-1), abs(n-b))
    ans = near + (diff+1)//2
    print(ans)
strargs = input()

n, a, b = map(lambda x: int(x), strargs.split())

if (b - a) % 2 == 0:
  print((b - a)//2)
  
elif a - 1 < n - b:
  newB = b - a
  mid = (newB - 1)//2 + 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)
# A - Table Tennis Training
N,A,B = map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min(A-1,N-B)+1+(B-A-1)//2)
N, A, B = map(int, input().split())
if abs(A - B) % 2 == 0:
  print (abs(A - B) // 2)
else:
  hajiniyoru = min(min(A - 1, B - 1), min(N - A, N - B))
  print(hajiniyoru  + 1 + (abs(A - B) - 1) // 2)
n,a,b=map(int,input().split())
if (a+b)%2==0:print(abs(a-b)//2)
else:
  aa,bb=1,b-a
  ans=a+abs(b-a)//2
  aa,bb=a+(n-b+1),n
  ans=min((n-b+1)+abs(b-a)//2,ans)
  print(ans)
n,a,b=[int(x) for x in input().split()]

if (a+b)%2==0:
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)
x=[]
N,A,B=map(int,input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    c=(A-1)+(B-A+1)//2
    d=(N-B)+(B-A+1)//2
    print(min(c,d))
N, A, B = map(int, input().split())

if (B-A) % 2 == 1:
    print(min(A-1, N-B)+1+(B-A-1)//2)
else:
    print((B-A)//2)
n,a,b = map(int,input().split())

if(( b-a ) % 2 == 0):
    print(((b-a)//2))
    exit()

print((min(a-1,n-b)+1+(b-a-1)//2))
n, a, b = map(int, input().split())

if a % 2 == b % 2:
  print((b - a) // 2)
else:
  distA = a - 1
  distB = n - b
  if distA < distB:
    ans = distA + (b - distA - 1) // 2
    if b - distA % 2 == 1:
      print(ans)
    else:
      print(ans + 1)
  else:
    ans = distB + (n - (a + distB)) // 2
    if a + distB % 2 == n % 2:
      print(ans)
    else:
      print(ans + 1)
n, a, b = map(int, input().split())
diff = abs(a - b)
if diff % 2 == 0:
    ans = diff // 2
else:
    ans = (diff - 1) // 2 + min(n - b, a - 1) + 1

print(ans)
n, a, b = map(int, input().split())
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)
N, A, B = map(int, input().split())


d = B-A
if d%2 == 1:
    d = min((B + (N-B)*2 + 1) - A, B - (A - (A-1)*2 - 1))

ans = d//2
print(ans)
N, A, B = map(int, input().split())
x = B - A
if x % 2 == 0:
    print(x//2)
else:
    # 左に持って行って寄せる
    l = (A-1) + 1 + (B-A-1)//2
    # 右に持って行って寄せる
    r = (N-B) + 1 + (B-A-1)//2
    print(min(r, l))
n, a, b = [int(i) for i in input().split()]
a_distance = a-1
b_distance = n-b
ab_distance = b - a

if ab_distance % 2 == 0:
  result = ab_distance//2
else:
  if a_distance < b_distance:
    result = a_distance + (ab_distance-1)//2 + 1
  else:
    result = b_distance + (ab_distance-1)//2 + 1
print(result)
N,A,B = map(int,input().split())
if (A + B) % 2 == 0:
  print(B - (A + B) // 2)
else:
  print(min(N - B,A - 1) + 1 + (B - A - 1) // 2)
n,a,b=map(int,input().split())
ans=0
if (b-a)%2 == 0:
	ans = (b-a)//2
else:
	if (b-1) < (n-a):
		ans = min(n-a, b-1, a+(b-a-1)//2)
	else:
		ans = min(n-a, b-1, n-b+1+(b-a-1)//2)
print(ans)
n, a, b = map(int, input().split())
if (a+b)%2:
  if a-1 <= n-b:
    print(a+(b-a-1)//2)
  else:
    print(n-b+1+(n-(a+n-b+1))//2)
else:
  print((b-a)//2)
n,a,b = map(int,input().split())

k = b-a
if k %2 == 0:
    print(k//2)
else:
    p = a-1
    bb = b-(a-1)

    p += 1
    bb -= 1
    
    res = p + (bb-1)//2


    p = n-b
    aa = a+(n-b)

    p += 1
    aa += 1

    res = min(res,p + (n-aa)//2)
    print(res)
N,A,B=map(int,input().split())
if (B-A)%2==0:
 print((B-A)//2)
else:
 print(min((A+B-1)//2,(2*N-A-B+1)//2))
n,a,b = map(int,input().split())

if (b-a) % 2 == 0:
	ans = (b-a) // 2
else:
	if a-1 < n-b:
		ans = b-1
		x = b-(a-1)-1
		ans = min(ans, a + (x-1) // 2)
	else:
		ans = n-a
		x = a + (n-b) + 1
		ans = min(ans, (n-b) + 1 + (n-x) // 2)

print(ans)
n, a, b = map(int, input().split())
d = abs(a-b)
if d % 2 == 0:
    print(d//2)
else:
    import math
    res = min(a-1, n - b)
    res += (d+1)//2
    print(res)
n,a,b=map(int,input().split())
x=b-a
p=print
if (b-a)%2==0:p((b-a)//2)
else:p(min(n-b+1+(x-1)//2,a+x//2))
N,A,B = map(int,input().split())
if A%2 != 0 and B%2 == 0:
  ans = (B-A-1)//2 + min(A-1,N-B) + 1
elif A%2 == 0 and B%2 != 0:
  ans = (B-A-1)//2 + min(A-1,N-B) + 1
else:
  ans = (B-A)//2
print(ans)
import sys

input = sys.stdin.readline

n, a, b= map(int, input().split())

if (b-a)%2 ==0:
    print((b-a)//2)

else:
    min_sabun = min(a-1,n-b)
    kyori = (b-a-1)//2
    print(min_sabun+kyori+1)
n,a,b=map(int,input().split())
if b<a:b,a=a,b
ans=float("inf")
if abs(a-b)%2==0:print(abs(a-b)//2)

else:
    print(min(n-b+1,a)+abs(b-a-1)//2)
def resolve():
    N, A, B = list(map(int, input().split()))

    if abs(A-B) % 2 == 0:
        print((B - A) //2)
    else:
        print(min(A, N-B+1) + (B -A -1) // 2)
    return

resolve()
n,a,b = map(int,input().split())

if (a+b) % 2 == 0:
    print(b - (a+b)//2)
else:
    if a <= n-b+1:
        b -= a
        print(a + b-(1+b)//2)
    else:
        a += n-b+1
        print(n-b+1 + n - (n+a)//2)
x,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min( a + (b-a-1)//2, x - b + 1 + (b-a-1)//2) )
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff + 1) // 2

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff + 1) // 2

    ans = min(ans1, ans2)

print(ans)
n, a, b = map(int, input().split())

if (b-a)%2 == 0:
    ans = (b-a)//2
else:
    ans = (b-a)//2 + min(a-1, n-b) + 1
print(ans)
n, a, b = map(int, input().split())
if (a - b) % 2 == 0:
    print((b - a) // 2)
else:
    print(min(a - 1, n - b) + (b - a) // 2 + 1)
N,A,B=map(int,input().split())
if (A-B)%2:
  a,b=min(A,B),max(A,B)
  if a-1<N-b:
    print((b-a-1)//2+a)
  else:
    print((b-a-1)//2+(N-b+1))
else:
  print(abs(A-B)//2)
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B-A) // 2)
else:
    print(min(A-1, N-B) + 1 + (B-A-1)//2)
N,A,B=map(int,input().split())

if (B-A)%2==0:
    print((B-A)//2)
else:
    if A+B-1>=2*N-A-B+1:
        print((2*N-A-B+1)//2)
    else:
        print((A+B-1)//2)
n,a,b = map(int,input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  print(min(b+a-1,2*n-b-a+1)//2)
N, A, B = [int(i) for i in input().split()]
if((B-A)%2==0):
    print((B-A)//2)
else:
    x = min(A-1, N-B)
    print((B-A-1)//2 + x + 1)
n,a,b=map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min((b+a-1)//2,(2*n-a-b+1)//2))
n, a, b = list(map(int, input().split()))

s = 0
if (a-b) % 2 == 0:
    s = abs(a-b) // 2
else:
    s = min((a+b-1)//2, (2*n - a-b +1)//2)

print(s)
n, a, b = map(int, input().split())
if (b-a)%2==0:
  print((b-a)//2)
else:
  print(min((a+b-1)//2,(2*n-a-b+1)//2))
n,a,b=map(int,input().split())

if ((b-a)%2==0):
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
	print((B - A) // 2)
else:
	print(min((A - 1),(N - B)) + 1 + (B - A - 1) //
 2)
N, A, B = map(int, input().split())
if (B-A)%2 == 0:
  print((B-A)//2)
else:
  if (N-B) >= A:
    print((B+A-1)//2)
  else:
    print((N-B+N-A+1)//2)
N,A,B = map(int,input().split())

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+1+abs(A-B+1)//2)
n,a,b = map(int,input().split())

d = abs(b-a)
if(d % 2 == 0):
    print(d//2)
else:
    c = min(a-1,n-b)
    c += 1
    d = abs(b-a-1)
    print(c + d // 2)
N,A,B = map(int,input().split())
n = B - A
if n % 2 == 0:
    print(n//2)
else:
    if min(B-1,N-A) == B-1:
        print(A+(B-A-1)//2)
    else:
        print(N-B+1+(-A+B-1)//2)
n, a, b = [int(i) for i in input().split()]
res = (b-a) // 2 if (b-a) % 2 == 0 else min(a-1, n-b) + 1 + (b-a-1)//2
print(res)
N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
  ans = (B-A) // 2
else:
  ans = min(A-1, N-B) + 1 + (B-A-1) // 2
print(ans)
# ans

N, A, B = map(int, input().split())

if abs(A-B) % 2 == 0:
  print(abs(A-B) // 2)
else:
  print(min((B-A-1)//2 + A, (B-A-1)//2 + (N - B + 1)))
n,a,b=map(int,input().split())
if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    print(min(a-1, n-b) + 1 + (b-a)//2)
N, A, B = map(int, input().split())
if (B - A) % 2:
    print(min(A - 1, N - B) + (B + 1 - A) // 2)
else:
    print((B - A) // 2)
#!/usr/bin/env python3

def f(n,a,b):
    if (a + b) % 2:
        return min(a-1,n-b) + 1 + (b-a-1)//2
    else:
        d = b-a
        return d//2

def main():
    N,A,B = map(int,input().split())
    print(f(N,A,B))

if __name__ == '__main__':
    main()
n, a, b = map(int, input().split())

if (a + b) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2
print(ans)
N,A,B=map(int,input().split(' '))
if abs(B-A)%2==0:
    print(abs(B-A)//2)
else:
     l = min(A-1,B-1)+1+(abs(A-B)-1)//2
     r = min(N-A,N-B)+1+(abs(A-B)-1)//2
     print(min(l,r))
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N, A, B = map(int, input().split())
dis = B - A - 1
if dis % 2 == 0:
    print(min((N - max(A, B) + 1) + (N - min(A, B) - (N - max(A, B) + 1)) // 2,
          min(A, B) + ((max(A, B) - min(A, B) - 1) // 2)))
else:
    print((dis + 1) // 2)
N, A, B = [int(_) for _ in input().split()]
d = B - A
if d % 2:
    t1 = N - B + 1
    ans = t1 + (N - (A + t1)) // 2
    t2 = A
    ans = min(ans, t2 + (B - t2 - 1) // 2)
    print(ans)
else:
    print(d // 2)
n, a, b = list(map(int, input().split()))

if (a-b) % 2 == 0:
    print(abs(a-b)//2)
else:
    x = ((a-1) + (b-1) + 1)//2
    y = ((n-a) + (n-b) + 1)//2
    print(min(x, y))
n,a,b = map(int, input().split())

ans = (b-a)//2
if (b-a)%2 == 1:
    ans += 1 + min(a-1,n-b)
print(ans)
N, A, B = map(int, input().split())

if (B-A)%2 == 0:
    ans = (B-A)//2
else:

    top = N-A
    bottom = B-1
    ans = min(A-1, N-B) + 1 + (B-A-1)//2

print(ans)
n,a,b = map(int,input().split())
s = abs(a-b)
if s % 2 == 0:
    print(s // 2)
else:
    print(min(a-1,n-b)+1+((b-a-1) // 2))
i=raw_input()
N,A,B=i.split()

N = int(N)
A = int(A)
B = int(B)

if abs(A-B)%2==0:
  print abs(A-B)/2
else:
  e=min(A-1,N-B)
  d=(B-A+1)/2
  print e+d
n, a, b = map(int, input().split())
ans = 0
if (a - b) % 2 == 0:
  ans = (b - a)// 2
else:
  ans = min(a + (b - a - 1) // 2, n - b + (b - a + 1) // 2)
print(ans)
N, A, B = map(int, input().split())

A, B = min(A, B), max(A, B)
d = B - A
if d % 2 == 0:
    print(d // 2)
else:
    if (A - 1 <= N - B):
        A, B = A - 1, B - 1
    else:
        A, B = N - B, N - A
    ans = min(B, A + 1 + (B - A - 1) // 2)
    print(ans)
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    print((b-a)//2)
else:
    print(min(a-1, n-b)+1+(b-a-1)//2)
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    ans = (b - a) // 2
else:
    ta = a + ((b - a - 1) // 2)
    tb = n - b + 1 + ((b - a - 1) // 2)
    ans = min(ta, tb)
print(ans)
# https://atcoder.jp/contests/agc041/tasks/agc041_a¥

n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
    ans = (b - a) // 2
else:
    ans = min(a - 1, n - b) + 1 + (b - a - 1) // 2
print(ans)
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, A, B = mi()
    if (B-A)%2==0:
        print((B-A)//2)
    else:
        print(min(A+(B-A-1)//2, N-B+1+(B-A-1)//2))


if __name__ == '__main__':
    main()
n, a, b = map(int, input().split())
d = min((b - a - 1) // 2 + a, (n - b + 1 + (b - a - 1) // 2))

if (b - a) % 2 == 0:
    d = (b - a) // 2

print(d)
n,a,b=map(int,input().split())
if (a-b)%2:
    print(min(n-b+1+(b-1-a)//2,a-1+1+(b-a-1)//2))
else:
    print(abs(a-b)//2)
n, a, b = map(int, input().split())
# 偶奇一致
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    left = a - 1
    right = n - b

    if left > right:
        cnt = right + 1
        left = min(a + cnt, n)
        print((n - left) // 2 + cnt)
    else:
        cnt = left + 1
        right = max(b - cnt, 1)
        print((right - 1) // 2 + cnt)
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  print(min(a - 1, n - b,) + 1 + (b - a - 1) // 2)
N,A,B=map(int,input().split())
if (B+A)%2==0:
    ans=(B-A)//2
else:
    ans=min(A-1,N-B)+1+(B-A-1)//2
print(ans)
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, readline().split()))
    if (b - a) % 2 == 0:
        print((b - a) // 2)
    else:
        print(min(a - 1, n - b) + (b - a - 1) // 2 + 1)


if __name__ == '__main__':
    solve()
N, A, B = map(int, input().split())
print((B - A) // 2 if (B - A) %
      2 == 0 else min(A - 1, N - B) + 1 + (B - A - 1) // 2)
n,a,b=map(int,input().split())
if a>b: a,b=b,a

if (a-b)%2==0: print((b-a)//2)
else: print(min(a-1,n-b)+1+(b-a-1)//2)
n,a,b=map(int,input().split())
k=b-a
if k%2==0:
    print(k//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2) #先抵达最前或最后一张桌子，原地等待一次
n, a, b = map(int, input().split())
if (a%2 and b%2) or (a%2==0 and b%2==0):
  print((b-a)//2)
else:
  print(min(a-1, n-b)+1+(b-a-1)//2)
N, A, B = [int(_) for _ in input().split()]

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    X = A + ((B - A) - 1) // 2
    Y = (N - B + 1) + (N - (A + (N - B + 1))) // 2
    print(min(X, Y))
n, a, b = map(int,input().split())

d = b - a
if d % 2 == 0:
    print(d//2)
else:
    do = min(a-1,n-b)
    print(do+1+(b-a-1)//2)
N, A, B = map(int, input().split())
d = A - B if A > B else B - A
d2 = d // 2
d3 = d % 2
if d3 == 0:
  ans = d2
else:
  bigger = B
  smaller = A
  if A > B:
    bigger = A
    smaller = B
  shortest = smaller if N - bigger + 1 > smaller else N - bigger + 1
  ans = shortest + d2
  
  

print(ans)
n,a,b = map(int, input().split())
if (b-a)%2==0:
    ans = (b-a)//2
else:
    # ans = min(n-a, b-1)
    # ans = min(ans, min(a-1, n-b) + (b-a-1)//2 + 1)
    ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)
N, A, B = map(int, input().split())

dif = B-A
if dif%2 == 0:
  print(dif//2)
else:
  print(min(A-1, N-B)+1+dif//2)
n,a,b=map(int,input().split())
if (a+b)%2==0:
    print((b-a)//2)
else:
    if n-b>=a-1:
        print((a+b-1)//2)
    else:
        print(n+(1-a-b)//2)
n,a,b = map(int,input().split())
if (a % 2 + b % 2) % 2 == 0:
    print(abs(a - b) // 2)
elif n - b < a - 1:
    p = n - b + 1
    a += n - b
    b = n
    print(abs(a - b) // 2 + p)
else:
    p = a
    b -= a - 1
    a = 1
    print(abs(a - b) // 2 + p)
n,a,b = [int(x) for x in input().split()]

if (b - a) % 2 == 0:
    print((b-a)//2)
else:
    print(min((a-1), (n-b))+ 1 + (b-a-1)//2)
N, A, B = map(int, input().split())

if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min(A-1, N-B)+1+(B-A-1)//2)
n, a, b = map(int, input().split())
if (b-a)%2 == 0:
  print((b-a)//2)
elif n-b < a-1:
  print((b-a-1)//2 + n-b+1)
else:
  print((b-a-1)//2 + a)
n,a,b = map(int, input().split())
if abs(a-b)%2 ==0:
    print(abs(a-b)//2)
else:
    to_one_or_n = min(min(a,b) -1, n - max(a,b))
    wait = 1
    face_to_face = (abs(a-b) - 1)//2
    print(to_one_or_n + wait + face_to_face)
N, A, B = map(int, input().split())

if (B - A)%2 == 0:
    print((B - A)//2)
else:
    if A - 1 > N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + N - B)
    elif  A - 1 <= N - B and B - A - 1 != 0:
        print((B - A + 1)//2 + A - 1)
    elif A - 1 > N - B and B - A - 1 == 0:
        print(N - B + 1)
    else:
        print(A)
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	if (B - A) % 2 == 0:
		ans = int((B - A) // 2)
		print(ans)
	else:
		ans = min(int((2 * N + 1 - A - B) // 2), int((A + B - 1) // 2))
		print(ans)
	


if __name__ == '__main__':
	main()
N,A,B=map(int,input().split())

if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min(N-B,A-1)+(B-A+1)//2)
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    ans=0
    if (b-a) % 2 == 0:
        print((b-a) // 2)
    else:
        print((b-a)//2 + min(a-1,n-b) + 1)

if __name__=="__main__":
    main()
n,a,b = map(int,input().split())

if (b-a)%2==0:
    print((b-a)//2)
else:
    if n-a < b-1:
        print((b-a-1)//2+n-b+1)
    else:
        print((b-a-1)//2+a)
n, a, b = map(int, input().split())
result = 0
if (b - a)%2 == 1:
    temp1 = a - 1
    temp2 = n - b
    work = temp1 if temp1 < temp2 else temp2
    if (b-a)//2 == 1:
        result = work
    else:
        result = work + 1 + (b-a-1)//2
else:
    result = (b - a) // 2
print(result)