peterverebics/CodeNet_Python_118 huggingface dataset:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, a, b = MI()
    d = b - a
    ans = 0
    if d%2:
        ans = min(n-a, b-1)
    else:
        ans = d//2
    print(ans)

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

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

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

ans = float("inf")
if (b-a)%2:
    ans = min((b-a+1)//2+a-1, ans)
    ans = min((a+n-b+1)//2+n-b, ans)
else:
    ans = (b-a)//2
print(ans)
def tableTennis():
    N,A,B = map(int,input().split())
    roundTime = 0
    if (B - A)%2 == 0:
        roundTime = (B - A)/2
    else:
        harfN = N/2 
        if harfN <= A:
            roundTime = N - A
        else:
            roundTime = min(A - 1,N - B) + 1 + (B-A-1)/2
            
    print(int(roundTime))



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

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    ans = min(B - 1, N - A)
    print(ans)
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:
        c = 1
        d = B
        e = A
    else:
        c = N
        d = A
        e = B
    
    print(e+(d-e-c)//2)
#agc041 a
n,a,b=map(int,input().split())
ans=0
if (b-a)%2==0:
    ans=int((b-a)/2)
else:
    left=a-1
    right=n-b
    ans=min(left,right)+b-a
print(ans)
N, A, B = map(int, input().split())

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

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

if a+1 == b:
    ans = b-1

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

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

if( (A-B)%2 == 0):
  print( (A-B)/2 )
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    print(min(a+(b-a)//2,b+(b-a)//2))
N,A,B= map(int,input().split())
if (B-A)%2 == 0:
  print((B-A)//2)
else:
  print(min(A,B-N)+1+(B-A-1)//2)
n,a,b=map(int,input().split())
if (b-a-1)%2==1:
    print((b-a-1)//2+1)
else:
    if b-1<=n-a:
        print(b-1)
    else:print(n-1)
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(max(A, B) - 1, N - min(A, B)))
else:
    print(dis + 1 // 2)
n, a, b= map(int,input().split())
if (b-a) % 2 == 0:
    print((b-a)//2)
elif (b-a) % 2 == 1:
    print(min(a-1+1+(b-a)//2,n-b+1+(a-n+b-1)//2))
n, a, b = map(int,input().split())
if (b-a)%2 == 0:
    print(int((b-a)/2))
else:
    if n-b <= a:
        print(n-a-1)
    else:
        print(b-1)
N,A,B = map(int,input().split())
n = min(N-A,B-1)
if (B-A)%2==0:
    print(min((B-A)//2,n))
else:
    print(n)
N, A, B = map(int,input().split())

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

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(int(solve(n, a, b)))
N, A, B = map(int, input().split())

left = B-1
right = N-A
mid = (B - A)//2

if (B - A)%2==0:
    print(min([left, right, mid]))
else:
    print(min(left, right))
[N,A,B] = list(map(int,input().split()))
if A%2==B%2:
    output = int(abs(A-B)/2)
else:
    if A-1<=N-B:
        output = A-1+1
        B = B-(A-1+1)
        output += int(abs(1-B)/2)
    else:
        output = N-B+1
        A =  A+(N-B+1)
        output += int(abs(A-N)/2)
print(output)
from math import ceil
n ,a, b =  map(int, input().split())
dif = abs(a-b)
ans = 0
if dif == 1 and max(a,b) <= ceil(n/2):
  ans = abs(1-max(a,b))
elif dif == 1 and min(a,b) >= ceil(n/2):
  ans = abs(n-min(a,b)) 
elif dif >= 2:
  ans = dif//2
print(ans)
n,a,b = map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2)
else:
    ret1 = a+(b-a+1)//2
    ret2 = n-b+1+(b-a-1)//2
    print(min(ret1, ret2))
N,a,b=map(int,input().split())

if (b-a)%2==0 :
    print(((b-a)/2))
else:
    print(min(b-1,N-a,int(N-b+(b-a+1)//2),int(a+(b-a-1)//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-1) + (n-b) + 1)/2
    print(min(x, y))
import math
n, a, b = map(int, input().split())
print(min(n-min(a, b), max(a, b)-1) if (a-b)%2 else math.ceil(abs(a-b)/n))
N, A, B = map(int, input().split(" "))

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

if (b - a) % 2 == 0:
  print(int(b - (a+b)/2))
else:
  if (a - 1) >= (n - b):
    print((n-b) + 1 + int(n - (n+a+(n-b)+1)/2))
  else:
    print("a")
    print((a-1) + 1 + int(b-(a-1)-1 - (b-(a-1)-1 + 1)/2))
import sys
input = sys.stdin.readline

# A - Table Tennis Training
def move_left():
	return A + (B-A-1)//2


def move_right():
	return  N - B + 1 + (B-A-1)//2	


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

if (B-A) % 2 == 0:
	print(int((B-A)/2))
else:
	l = move_left()
	r = move_right()
	print(min(l, r))
N, A, B = map(int, input().split())

if abs(A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    left = max(A, B) - 1
    right = N - min(A, B)
    print(min(left, right))
n,a,b=map(int,input().split())
ans=float("inf")
if abs(a-b)%2==0:ans=abs(a-b)//2
print(min(ans,max(a,b)-1,n-min(a,b)))
n,a,b = map(int, input().split())
print(min(n-a,b-1) if (b-a)%2!=0 else (b-a)//2)
N, A, B = map(int, input().split())


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

ans = d//2
print(ans)
n,a,b=map(int,input().split())
if (a-b)%2==0:
    print(abs(a-b)//2)
else:
    print(min(max(a-1,b-1),max(n-a,n-b)))
# 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()
N, A, B = map(int, input().split())
if (A - B) % 2 == 0:
  print (abs(A - B) // 2)
else:
  print(min(max(A, B) - 1,N - min(A, B)))
n,a,b = map(int,input().split())
if abs(b - a)%2 == 0:
    print(abs(b - a)//2)
else:
    print(min(max(abs(1-a),abs(1-b)),max(abs(n-a),abs(n-b))))
N,A,B=map(int,input().split())
if (B-A)%2==0:
  print((B-A)//2)
else:
  print(min(A-1,2*N-B))
n,a,b=map(int,input().split())
print(abs(a-b)//2 if (a-b)%2==0 else max(a,b)-1)
#!/usr/bin/env python3
N, A, B = [int(str) for str in input().strip().split()]

if (B - A) % 2:
    left = B - 1
    right = N - A
    print(min(left, right))
else:
    print((B - A) // 2)
def main(n: int, a: int, b: int):
    if abs(a - b) % 2 == 0:
        print(abs(a - b) // 2)
    else:
        print(abs(a - b) * 2)


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

Abs = B - A
if Abs % 2 == 0:
  ans = Abs // 2
else:
  A, B = A - 1, N - B
  ans = B if A < B else A
    
print(ans)
strargs = input()

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

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

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

right = max([A,B])
left = min([A,B])

if (right-left)%2 == 0:
    ans = [N-left,(right-left)//2,right-1]
    print(min(ans))
else:
    ans = [N-left,right-1]
    print(min(ans))
n, a, b = map(int, input().split())

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


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

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

print(ans)
import numpy as np
N,A,B = map(int,input().split())
x=abs(A-B)
if x%2==0:
    print(x//2)
else:
    print(x//2+1)
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-1) + (n-b) + 1)//2
    print(min(x, y))
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    print(min(n - a, b - 1))
N,A,B = map(int, input().split())
if (B-A)%2==0:
    print((B-A)//2)
else:
    print(min(B-1, N-A))
N,A,B = map(int, input().split())
ans = min(B-1,N-A) 
if (B-A)%2 == 0:
    #真ん中でも会える
    ans = min(ans,(B-A)//2)
print(ans)
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] - n[1]
  print(ans//2)
else:
  ans = n[2] - 1
  print(ans)
n, a, b = map(int, input().split())

if b-a % 2:
    ans = max(abs(1-a), abs(b-n))
else:
    ans = b-a-1

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

if abs(A-B) % 2 == 0:
  print(abs(A-B) // 2)
  exit()
  
print(min(max(A-1,B-1),max(N-A,N-B)))
def solve(N, A, B):
    return int(min(A - 1, N - B) + 1 + (B - A - 1)//2)

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

if (b-a)%2:
    ans = min(max(a-1, b-1), max(n-a, n-b))
else:
    ans = (b-a)//2
print(ans)
N=[int(e) for e in input().split()]

a=N[1]
b=N[2]

if (b-a)%2==0 :
    print(int((b-a)/2))
else:
    print(min(b-1,N[0]-a,int(N[0]-b+(b-a+1)/2),int(a+(b-a-1)/2)))
n , l ,  r = list( map( int ,input().split() ))
if (r - l) % 2 == 0:
  a = (r - l) //2
  print(a)
else: print(min( r -1 , n - l ))
N, A, B =map(int,input().split())
d = abs(B-A)
ans = 0
if d % 2 == 0:
    ans = d // 2
else:
    ans = int(min(N-B, A-1) + 1 + (B-A-1)/2)
    '''
    if N - B >= A - 1:
        ans = B - 1
    else:
        ans = N - A
'''

print(ans)
s = input().split()
n=int(s[0])
a=int(s[1])
b=int(s[2])

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

if (b - a)%2 == 0:
    print((b-a)//2)
else:
    if a-1 <= n-b:
        print(b-1)
    else:
        print(n-a)
N,A,B=map(int,input().split())
ans=0
if (B-A)%2==0:
	ans=(B-A)//2
	print(ans)
else:
	if B>N-A:
		print(N-A-1)
	else:
		print(B-1)
N, A, B = map(int, input().split())
C=B-A
D=max(A-1,N-B)
if C%2==1:
    print (D)
else:
    print(min(C,D))
def solve():
    N, A, B = [int(i) for i in input().split()]
    if (A - B) % 2 == 0:
        print(int(abs(A - B) / 2))
    else:
        print(min(N - min(A, B), max(A, B) - 1))

if __name__ == "__main__":
    solve()
N,A,B=map(int,input().split())
if ((A%2!=0) == (B%2!=0)) or (((A%2==0) == (B%2==0))):
    ans=abs(A-B)/2
else:
    ans=min(N-A,B-1)
print(int(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:
  mid = (b - a) - 1
  print(a + mid - 1)

else:
  newA = (a + (n - b + 1))
  mid = newA + (n - newA)//2
  print((n - b + 1) + (n - newA)//2)
N, A,B = map(int, input().split())
ab = abs(A-B)
ab_ = (A+B)/2
if ab%2 ==0:
  print(ab//2)
else:
  if ab_ > N/2:
    if A > B:
      print(B)
    else:
      print(A)
  else:
    if A > B:
      print(A-1)
    else:
      print(B-1)
n, a, b = list(map(int, input().split(" ")))

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

ans=[]
if (A-B)%2==0:
    ans.append((B-A)//2)
ans.append(B-1)
ans.append(N-A)

print(min(ans))
N, A, B = list(map(int,input().split()))
if abs(A-B) % 2 == 0:
  print(abs(A-B)//2)
else:
  print(max(A-1,B-1))
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())

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

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

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

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

if __name__ == "__main__":
    solve()
n,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    if n-b >= a-1:
        ans = a-1
        ans += (b-ans-1)//2
        print(ans+1)
    else:
        ans = n-b
        ans += (b-(a+n-b))//2
        print(ans+1)
n, a, b = map(int, input().split())
if a % 2 == b % 2:
    print((b - a) // 2)
else:
    if a > n - b + 1:
        print(n - a)
    else:
        print(b - 1)
    #print(max(a, n - b + 1) - 1)
n,a,b=map(int,input().split())
if (b-a-1)%2==1:
    print((b-a-1)//2+1)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2+1)
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

dis = B - A
if dis % 2 == 0:
    ans = dis // 2
else:
    ans = 1 + (B - A + 1) // 2
print(ans)
N,A,B = map(int,input().split())
if (A-B) % 2 == 0:
  print(int((B-A)/2))
elif A >= N-B:
  print(int((A+B-1)/2))
else:
  print(int((B-A-1)/2))
N, A, B = map(int, input().split())
if (B - A - 1) % 2 == 1:
  ans = (B - A ) / 2
else:
  ans = min((N - A),(B - 1))
  
print(int(ans))
i = 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:
  print(min(max(A-1, B-1), max(N-A, N-B)))
N,A,B=map(int,input().split())
ans=0
if (B-A)%2==0:
	ans=(B-A)//2
	print(ans)
else:
	if A < N-B:
		print(B-1)
	else:
		print(N-A)
n, a, b = map(int, input().split())
if (b-a)%2: b-=a; print((b-1)//2+a)
else: print((b-a)//2)
n,a,b = map(int, input().split())
ans = min(max(a-1,b-1),max(n-a,n-b))
if (b-a)%2 == 0:
    ans = min(ans,(b-a)//2)
print(ans)
n, a, b = map(int, input().split())

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

if (B-A)%2 == 0:
  count = (B-A)/2
else:
  count = min(N-B, A-1) + 1 + ((B-A-1)/2)
  
print(int(count))
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 (a+b) % 2 == 0:
  print((b-a)//2)
else:
  print(min(b-1, n-a))
i = input()
N, A, B = i.split()

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

if (B-A)%2 == 0:
  print((B-A)/2)
else:
  e = int(min(max(A-1, B-1), max(N-A, N-B)))
  d = (B-A) // 2 
  print(e - d)
n, a, b = map(int, input().split())
if (b - a) % 2 == 0:
    print(int((b - a) / 2))
elif b - a == 1:
    print(min(a - 1, n - b) + 1)
else:
    if a == 1 or b == n:
        print(int((b - a - 1) / 2 + 1))
    else:
        if a - 1 <= n - b:
            print(int(a + ((b - a - 1) / 2)))
        else:
            print(int(n - b + 1 + ((b - a - 1) / 2)))
n , l ,  r = list( map( int ,input().split() ))
a = 10**18
if (l - r % 2) == 0:
  a = (l - r) //2
a = min( a , min( r -1 , n - l ))
print(a)
N, A, B =map(int,input().split())
d = abs(A-B)
ans = 0
if d % 2 == 0:
    ans = int(d / 2)
else:
    if N - B >= A -1:
        ans = B -1
    else:
        ans = N - A

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

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

Abs = A - B
if Abs % 2 == 0:
  ans = Abs // 2
else:
  A, B = N - A, B - 1
  ans = A if A < B else B
    
print(ans)
from decimal import *
def resolve():

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

    print(int(ans))

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

if (b-a)%2 == 0:
    print(int((b-a)/2))
else:
    if a <= n-b:
        t = a + int((b-a)/2)
    else:
        t = n-b + int((b-a)/2)
    print(t)
N, A, B = map(int, input().split())
dis = B - A
if dis % 2 == 0:
    print(dis // 2)
else:
    A_end = A - 1
    B_end = N - B
    if A_end <= B_end:
        ans = A_end
        A = 1
        B -= A_end
        ans += 1
        print(ans + (B - A) // 2)
    else:
        ans = B_end
        B = N
        A -= B_end
        ans += 1
        print(ans + (B - A) // 2)
N,A,B = map(int, input().split(" "))
distance = abs(B - A)
res=0
if distance % 2 == 0:
  res = distance/2
else:
  a,b = min(A,B), max(A,B)
  ans = distance//2 + min(a-1, N-b)+1
N, A, B = list(map(int,input().split(" ")))

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

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

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

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

if (a % 2 == 0) and (b % 2 == 0):
  print((a + b) / 2)
  
else:
  print(int(min(n - a,b - 1)))
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 + 1

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

    ans = min(ans1, ans2)
    # print(ans1, ans2)

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

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

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

if abs(A-B) % 2 == 0:
    print(abs(A-B) // 2)
else:
    M1 = max(A-1, B-1)
    M2 = max(N-A, N-B)
    if M1 < M2:
        print(M1)
    else:
        print(M2)
def main():
    N,A,B = map(int,input().split())
    if abs(A-B)%2==1:
        top = max(A,B) - 1
        bottom = N - min(A,B)
        print(min(top,bottom))
    else:
        print(abs(A-B)//2)
if __name__ == '__main__':
    main()
n,a,b = map(int,input().split())
if (b-a)%2==0:
    print(int((b-a)/2))
else:
    print(int(min(a-1,n-b)+1+(b-1-a)//2))
N,A,B=map(int, input().split())
def find(N,A,B):
  if (A+B)%2==0:
    return int((B-A)/2)
  elif (A-1)>=(N-B):
    A=1-A
    return int((B-A)/2)
  
  elif (A-1)<(N-B):
    B=2*N-B
    return int((B-A)/2)
print(find(N,A,B))
N,A,B = map(int,input().split())
if abs(A-B)%2 == 1:
    num1 = max(N-A,N-B)
    num2 = max(A-1,B-1)
    print(min(num1,num2))
else:
    print(abs(A-B)//2)
n, a, b = map(int, input().split())

if (b - a) % 2 == 0:
	print(int((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(int((na + nb + 1) / 2))
	else:
		print(int((a1 + b1 + 1) / 2))
N,A,B=map(int,input().split())

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

if (b-a)%2 == 0:
    print((b-a)//2)
else:
    s = n//2
    if a > s and b > s:
        print(n - min(a,b))
    elif a<= s and b <= s:
        print(max(a,b) - 1)
    else:
        print(min(max(a,b)-1, n-min(a,b)))
n, a, b = map(int, raw_input().split())
if (b - a) % 2 == 0:
  print((b - a) // 2)
else:
  print(min(max(a - 1, b - 1), 
  			max(n - a, n - b),
  			max(a - 1, b - 1) + n // 2 + 1,
  			max(n - a, n - b) + n // 2 + 1
  ))
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

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

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

print(ans)