CodeEff/ECCO huggingface dataset:
# Original solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
Solved on 2019/3/
@author: shinjisu
"""


# ABC 056 C - Go Home
def getInt(): return int(input())
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替
class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob_TLE():
    d = Debug()
    d.off()
    X = getInt()
    d.dmp((X), 'X')
    pos = [0]
    for i in range(1, 10*9+1):
        nextPos = []
        for a in pos:
            nextPos.append(a-i)
            nextPos.append(a)
            nextPos.append(a+i)
        pos = nextPos
        d.dmp((pos), 'pos')
        if X in pos:
            break
    return i


def prob():
    d = Debug()
    d.off()
    X = getInt()
    d.dmp((X), 'X')
    pos = set([0])
    for i in range(1, 10**9+1):
        nextPos = set()
        for a in pos:
            nextPos.add(a-i)
            nextPos.add(a)
            nextPos.add(a+i)
        pos = nextPos
        #d.dmp((pos), 'pos')
        if X in pos:
            break
    return i


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


# Optimized solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
Solved on 2019/3/
@author: shinjisu
"""


# ABC 056 C - Go Home
def getInt(): return int(input())
def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替
class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    X = getInt()
    d.dmp((X), 'X')
    sm = 0
    for i in range(1, 10**9+1):
        sm += i
        if X <= sm:
            break
    return i


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)
# Original solution
X = int(eval(input()))

i, x = 1, 0
while x < X:
    x += i
    i += 1
print((i - 1))

# Optimized solution
import math
X = int(eval(input()))
print((math.ceil((-1 + (1 + 8 * X) ** 0.5) / 2)))
# Original solution
X=int(eval(input()))
count=0
x=[[0]]
for k in range(0,1000000):
    if X in x[k]:
        print(k)
        break
    x.append(list(set(x[k])))
    for j in range(len(x[k])):
        x[k+1].append(x[k][j]+k+1)
        x[k+1].append(x[k][j]-k-1)
    x[k+1]=list(set(x[k+1]))


# Optimized solution
X=int(eval(input()))
N=int(-0.5+(0.25+2*X)**0.5)

for k in range(N+2):
    if 0.5*N*(N-1)<X<=0.5*N*(N+1):
        print(N)
        break
    N+=1

'''
count=0
x=[[0]]
for k in range(0,1000000):
    if X in x[k]:
        print(k)
        break
    x.append(list(set(x[k])))
    for j in range(len(x[k])):
        x[k+1].append(x[k][j]+k+1)
        x[k+1].append(x[k][j]-k-1)
    x[k+1]=list(set(x[k+1]))
'''
# Original solution
X = int(eval(input()))
t = 1
while True:
    if X<=((t+1)*t)//2:
        break
    t += 1
print(t)


# Optimized solution
X = int(eval(input()))
k = 1
while (k*(k+1))//2<X:
    k += 1
print(k)
# Original solution
X = int(eval(input()))
k = 1
while (k*(k+1))//2<X:
    k += 1
print(k)

# Optimized solution
X = int(eval(input()))
t = 1
while X>(t*(t+1))//2:
    t += 1
print(t)
# Original solution
x=int(eval(input()))
import queue

q = queue.Queue()

q.put(0)
q.put("")
count=1
while 1:
    now=q.get()
    if now=="":
        count+=1
        q.put("")
        continue
    if now+count==x or now-count==x:
        print(count)
        break
    q.put(now+count)
    q.put(now)
    q.put(now-count)

# Optimized solution
x=int(eval(input()))
# import queue

# q = queue.Queue()

# q.put(0)
# q.put("")
i=0
now=0
while 1:
    i+=1
    now+=i
    if now>=x:
        print(i)
        break
# Original solution
a = int(eval(input()))
i = 1
R = 0
while a > R:
 R = R+i
 i = i+1
print((i-1))


# Optimized solution
n = int(eval(input()))
cou = 0
num = 0
while num < n:
  cou += 1
  num += cou
print(cou)
# Original solution
x = int(eval(input()))

i=1
cum=[0]
while cum[-1] < 10**9:
    cum+=[cum[-1]+i]
    i+=1

import bisect
index = bisect.bisect_left(cum, x)

print(index)

# Optimized solution
x = int(eval(input()))

i=1
while i*(i+1)//2 < x:
    i+=1

print(i)
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

x = int(read())
cumsum = list(itertools.accumulate([i for i in range(45000)]))
for i in range(45000):
    if cumsum[i] >= x:
        print(i)
        exit()


# Optimized solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

x = int(read())
cnt = 0
for i in range(45000):
    cnt += i
    if cnt >= x:
        print(i)
        exit()
# Original solution
x = int(eval(input()))
from collections import deque
q = deque([[0, 0]])
while q:
    xi, i = q.popleft()
    if xi == x:
        print((i-1))
        exit()
    q.append([xi, i+1])
    q.append([xi+i, i+1])
    q.append([xi-i, i+1])

# Optimized solution
x = int(eval(input()))
ans = 0
cnt = 0
i = 0
while cnt < x:
    i+=1
    cnt += i
    ans += 1
print(ans)
# Original solution
X = int(eval(input()))

i = 1
while((i ** 2 + i) / 2 < X):
  i += 1

print(i)

# Optimized solution
from math import ceil
x = int(eval(input()))
print((ceil(((1 + 8 * x) ** 0.5 - 1) / 2)))
# Original solution
if __name__ == '__main__':
    x = abs(int(eval(input())))

    s = 0
    for i in range(0,10 ** 9):
        if s > x: 
            print((i - 1))
            break
        elif s == x:
            print((i - 1))
            break
        s += i

# Optimized solution
if __name__ == '__main__':
    x = abs(int(eval(input())))

    s = 0
    for i in range(0,10 ** 9):
        if s >= x: 
            print((i - 1))
            break
        s += i
# Original solution
from collections import deque

X = int(eval(input()))

q = deque()
q.append((0, 1))

while len(q) > 0:
    pos = q.popleft()
    if pos[0] + pos[1] == X or pos[0] - pos[1] == X:
        print((pos[1]))
        break
    q.append((pos[0] + pos[1], pos[1] + 1))
    q.append((pos[0] - pos[1], pos[1] + 1))
    q.append((pos[0]         , pos[1] + 1))


# Optimized solution
X = int(eval(input()))
t = 1

while True:
    if t * (t + 1) / 2 >= X:
        print(t)
        break
    t += 1
# Original solution
X = int(eval(input()))
a = 1

while a*(a+1)//2<X:
  a+=1

print(a)

# Optimized solution
print((round((2*int(eval(input())))**.5)))
# Original solution
X = int(eval(input()))
queue = [(0,0)]
while queue:
  time, location = queue.pop(0)
  if location == X:
    print(time)
    break
  time+=1
  queue.append((time,location+time))
  queue.append((time,location))
  queue.append((time,location-time))

# Optimized solution
X = int(eval(input()))
t = 1
for t in range(1,X+1):
  total = t*(t+1)/2
  if total>=X:
    break
print(t)
# Original solution
X = int(eval(input()))
L = [sum(range(i+1)) for i in range(X+1) if sum(range(i+1))<X]
print((len(L)))

# Optimized solution
X = int(eval(input()))
for i in range(X+1):
    if (i*(i+1)/2) >= X:
        time = i
        break
print(time)
# Original solution
def main():
    X = int(eval(input()))
    ans = 1
    while ans * (ans + 1) * 0.5 < X:
        ans += 1
    print(ans)
    return


main()


# Optimized solution
from operator import rshift


def main():
    X = int(eval(input()))
    ans = 1
    while rshift(ans * (ans + 1), 1) < X:
        ans += 1
    print(ans)
    return


main()
# Original solution
# coding: utf-8
# Your code here!
X=int(eval(input()))

if X==1:
    print((1))
    exit()
elif X==2:
    print((2))
    exit()

l=[1]
i=2
while True:
    temp=[]
    for item in l:
        temp.append(item+i)
    if X in temp:
        print(i)
        exit()
    else:
        l+=temp
        i+=1

# Optimized solution
# coding: utf-8
# Your code here!
X=int(eval(input()))

i=0
count=0
while True:
    i+=1
    count+=i
    if count>=X:
        print(i)
        exit()
# Original solution
n = int(eval(input()))
l = []
def f(n, l):
  for i in range(1, n+1):
    sum = 0
    l.append(i)
    for j in range(len(l), 0, -1):
      if not sum + l[j-1] > n:
        sum += l[j-1]
      
      if sum == n:
        return i

print((f(n, l)))

# Optimized solution
n = int(eval(input()))
l = []

def f(n, l):
  sum = 0
  for i in range(1, n+1):
    sum += i
    if sum >= n:
      return i

print((f(n, l)))
# Original solution

X = int(eval(input()))

dic = {}
dic[0] = 1

time = 0

while True:

    time += 1

    dicc = dic.copy()
    for i in dicc:

        dic[i + time] = 1
        dic[i - time] = 1

    if X in dic:
        break

print (time)

# Optimized solution

X = int(eval(input()))

ans = 0
cnt = 0

while ans < X:
    
    cnt += 1
    ans += cnt


print (cnt)
# Original solution
import queue
t = int(eval(input()))

queue = queue.Queue()
queue.put([0,0])
while True :
	x = queue.get()
	if x[0] == t:
		print(x[1])
		break

	else :
		queue.put([ x[0]+x[1]+1 , x[1]+1 ])
		queue.put([ x[0] , x[1]+1])
		if x[0] - (x[1]+1) > 0 :
			queue.put([x[0]-(x[1]+1),x[1]+1])



# Optimized solution
n = int(eval(input()))

ans = 0
i = 1
while n > ans :
	ans += i
	i += 1

print(i-1)
# Original solution
X=int(eval(input()))
A=[]
for i in range(1,X+1):
    A.append(i)
    if sum(A)>=X:
        print(i)
        break

# Optimized solution
sum=0
X=int(eval(input()))
for i in range(1,X+1):
    sum+=i
    if sum>=X:
        print(i)
        break
# Original solution
import collections
ta = int(input())
vis = set([0])
q = collections.deque([(0,0)])
while(q):
	x,t = q.popleft()
	if x == ta:
		print(t)
		break
	for nt in [x-t-1,x,x+t+1]:
		q.append((nt, t + 1))




# Optimized solution
import collections
target = int(input())
t = 0
while(target):
	target -= min(target, t + 1)
	t +=1
print(t)
# Original solution
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
na = lambda : list(map(int, stdin.readline().split()))
ni = lambda : int(ns())
def main():
  n = ni()
  f = lambda x: (x * (x+1)) // 2
  for i in range(1, n+1):
    if (f(i) >= n):
      print(i)
      return
main()

# Optimized solution
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  t = 0
  for i in range(1, n + 1):
    t += i
    if t >= n:
      print(i)
      return
main()
# Original solution
from collections import deque

X = int(eval(input()))

queue = deque()
queue.appendleft((0, 0))

while queue:
    now = queue.pop()
    pos = now[0]
    time = now[1]

    if pos == X:
        print(time)
        exit()

    queue.appendleft((pos + time+1, time+1))
    queue.appendleft((pos, time+1))
    queue.appendleft((pos - (time+1), time+1))


# Optimized solution
X = int(eval(input()))

time = 0
pos = 0
while pos < X:
    time += 1
    pos += time

print(time)
# Original solution
n = int(eval(input()))
tot=0
dp = [0 for i in range(n+4)]
for i in range(1, n+1):
	tot=tot+i
	if tot>=n:
		print(i)
		break

# Optimized solution
n = int(eval(input()))
tot=0
for i in range(1, n+1):
	tot=tot+i
	if tot>=n:
		print(i)
		break
# Original solution
# -*- coding: utf-8 -*-

import itertools

def main():
    X = int(input())
    jumpTime = [ i for i in range(1,X+1) ]
    candidate = []
    for i in range(1, len(jumpTime)+1):
       candidate.append(list(itertools.combinations(jumpTime, i)))
    correct = []
    for can in candidate:
        for c in can:
            if sum(c) == X:
                correct.append(c)
    correctMax = list(map(max, correct))
    print(min(correctMax))
        

if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-

def main():
    X = int(input())
    step = 0
    for i in range(1,X+1):
        step += i
        if step >= X:
            break
    print(i)

if __name__ == '__main__':
    main()
# Original solution
X = int(eval(input()))
pos = [0]

for i in range(1,X+1):
	tmp = []
	for j in pos:
		tmp.append(j + i)
		if j + i ==  X:
			print(i)
			exit(0)

	pos.extend(tmp)
	pos = list(set(pos))


# Optimized solution
X = int(eval(input()))

sumval = 0
for i in range(1,X+1):
	sumval += i
	if sumval >= X:
		ans = i
		break

print(ans)
# Original solution
# ABC056 C - Go Home
X = int(eval(input()))

T = []
total = 0
idx = 0
ans = 0

while total < 2500000000:
    idx += 1
    total += idx
    T.append(total)

for i in range(len(T)-1):
    if i == 0:
        if X == T[i]:
            ans = i+1
            break
    if T[i-1]<X<=T[i]:
        ans = i+1
        break
print(ans)

# Optimized solution
x=int(eval(input()))
if x==1:
  print((1))
  exit(0)
for i in range(1,100001):
  t=i*(i+1)//2
  s=(i+1)*(i+2)//2
  if t<x<=s:
    print((i+1))
    exit(0)
# Original solution
from collections import deque
x = int(eval(input()))
que = deque()
count = 0

que.append((count, 0, 0, 0))

while len(que) > 0:
    depth, v1, v2, v3 = que.popleft()
    if any([val == x for val in (v1, v2, v3)]):
        break
    depth += 1
    for v in (v1, v2, v3):
        que.append((depth, v - depth, v, v + depth))

print(depth)


# Optimized solution
x = int(eval(input()))

t = 0
s = 0
while s < x:
    t += 1
    s += t
print(t)
# Original solution
X = int(eval(input()))
def bfs(position=[0],depth=1):
    queue = []
    for p in position:
        for dx in [-depth,0,depth]:
            nextp = p + dx
            if nextp == X:
                return depth
            queue.append(nextp)
    position = queue[:]
    if depth == 10**5:
        return depth
    return bfs(position,depth+1)
print((bfs()))

# Optimized solution
X = int(eval(input()))
for t in range(1,X+1):
    if t*(t+1)//2 >= X:
        print(t)
        break
# Original solution
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    def main():
        X=int(eval(input()))
        d=deque([1,0,-1])
        now=2
        while True:
            for i in range(3**(now-1)):
                dd=d.popleft()
                if dd==X:
                    return now
                else:
                    d.append(dd+now)
                    d.append(dd)
                    d.append(dd-now)
            now+=1
    print((main()-1))






resolve()

# Optimized solution
def resolve():

    X=int(eval(input()))
    cnt=1
    while True:
        val=cnt*(cnt+1)//2
        if val>=X:
            print(cnt)
            break
        else:
            cnt += 1


resolve()
# Original solution
#!/usr/bin/env python3
# BFS
from collections import deque

x = int(eval(input()))
q = deque()
q.append((0, 0))
visited = []

while q:
    u = q.popleft()
    if u[0] == x:
        print((u[1]))
        break
    visited.append(u)
    if ((u[0]-1, u[1]+1)) not in visited:
        q.append((u[0]-(u[1]+1), u[1]+1))
    if ((u[0], u[1]+1)) not in visited:
        q.append((u[0], u[1]+1))
    if ((u[0]+1, u[1]+1)) not in visited:
        q.append((u[0]+(u[1]+1), u[1]+1))

# Optimized solution
#!/usr/bin/env python3

x = int(eval(input()))
t = 0
while True:
    if t*(t+1)/2 >= x:
        print(t)
        break
    t += 1
# Original solution
import sys
from pprint import pprint

def solve(n, a, b):
    ans = 0
    if (b - a) % 2 == 0:
        ans = (b - a) // 2
    else:
        # 両端で試合するパターン
        simple = min(b - 1, n - a)

        # 両端に一回残留してから端以外で試合するパターン
        mix_a = a + (b - a) // 2
        mix_b = n - b + 1 + (b - a - 1) // 2
        ans = min(simple, mix_a, mix_b)

    print(ans)

if __name__ == '__main__':
    n, a, b = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, a, b)

# Optimized solution
import sys

N, A, B = list(map(int, sys.stdin.readline().split()))
if (B - A) % 2 == 0:
    print(((B - A) // 2))
else:
    print((min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2)))
# Original solution
N,A,B = list(map(int, input().split()))

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

# Optimized solution
"""
AtCoder Grand Contest 039  A - Connection and Disconnection


Sの中で、隣り合う文字が同じ場合、連続しないよう書き換える
・abba -> abca
・abbba -> abcba：奇数個連続している場合、（連続してる個数）// 2 書き換える
・abbbba -> abcbca：偶数個連続している場合、（連続してる個数）// 2 書き換える。奇数個と同じ

また、Sを並べていく中で、「Sの末尾の文字群」と「Sの先頭の文字群」が同じ場合も、書き換えが必要。
S = abcda
SSSSS = abcda abcda abcda abcda abcda

文字列の両端は、普通に処理するのでなく、同じ文字であれば合算する形で処理したい
aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaa aaabcdaaaだと、間にaが6こ続くパターンと、全体の両端にaaaがある、みたいな。

Sが全部同じ文字だと、話がちょっと違って、交互に違う文字が出るように変える。これがコーナーケースかな？


（被らせないために）使えない文字は多くても2文字なので、書き換え先について悩むことはない。
"""
"""
AtCoder Grand Contest 041  A - Table Tennis Training

勝った人がX-1の卓、負けた人がX+1の卓で、引き分けはないから、±1のどちらかが絶対におこる
A,Bの間の距離が偶数の時、一方が勝ち一方が負けることで、差が2埋まるから、(B-A)/2回の試合後に、二人が試合できるはず
距離が奇数だと、
・端っこの卓で出会う
・一方が一回端っこの卓で足踏みしてからお互いの距離が縮まるように勝敗を決める
だと思う→一回端っこで足踏みしたら、そこで待つ必要もないので、端っこで出会うはなくていいかも。
二人の距離が奇数かつ、差が1なら両端のどちらかで出会うし、そうでなければ、一回足踏みののち、出会う方向に移動する形か

A側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がa回で、そこから出会うまでが、(b-a-1) / 2回
B側で一回足踏みするなら、足踏みが終わるまでにかかる試合数がN-b+1回で、そこから出会うまでが、(N-(a+N-b+1)) / 2 = (b-a-1) / 2回
"""

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

if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    ans = min(A, N-B+1) + (B-A-1)//2
print(ans)
# Original solution
import sys
temp=list(map(int, input().split()))
N=temp[0]
A=temp[1]
B=temp[2]
cnt=0
if (B-A)%2==1:
  if A-1<=N-B:
    cnt=A
    B-=A
    A=1
  else:
    cnt=N-B+1
    A+=(N-B)+1
    B=N
while A!=B:
    if B-A>=2:
      A+=1
      B-=1
      cnt+=1
print(cnt)

# Optimized solution
import sys
temp=list(map(int, input().split()))
N=temp[0]
A=temp[1]
B=temp[2]
cnt=0
if (B-A)%2==1:
  if A-1<=N-B:
    cnt=A
    B-=A
    A=1
  else:
    cnt=N-B+1
    A+=(N-B)+1
    B=N
if A!=B:
  cnt+=(B-A)//2
print(cnt)
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,A,B = MI()

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



# Optimized solution
import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))


N,A,B = MI()
print(((B-A)//2 if (B-A) % 2 == 0 else min((A+B-1)//2,N-(A+B-1)//2)))
# Original solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n,a,b = list(map(int, input().split()))
l = min(a, b)
r = max(a, b)
k = r - l
if k % 2 == 1:
    count = min(l - 1, n - r) + 1 + ((k - 1) // 2)
    print((int(count)))
else:
    print((int(k // 2)))

# Optimized solution
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n,a,b = list(map(int, input().split()))
k = abs(a - b)
if k % 2 == 1:
    count = 0
    if n - b > a - 1:
        count += a - 1 + 1 + ((k - 1) // 2)
    else:
        count += n - b + 1 + ((k - 1) // 2)
    print((int(count)))
else:
    print((k // 2))
# Original solution
n, a, b = list(map(int, input().split()))

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


# Optimized solution
n, a, b = list(map(int, input().split()))


if (b - a)%2 == 0:
    ans = (b - a)//2
    print((int(ans)))
else:
    ans = min(a - 1, n - b) + 1 + ((b - a - 1)//2)
    print((int(ans)))
# Original solution
N, A, B = list(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))

# Optimized solution
N, A, B = list(map(int, input().split(" ")))

if (B - A) % 2 == 0:
    print(((B - A) // 2))
else:
    print((min(N - B, A - 1) + 1 + (B - A - 1) // 2))
# Original solution
nc, ac, bc = list(map(int, input().split()))

n = nc - 1
a = ac - 1
b = bc - 1

if (b - a) % 2 == 0:
    print(((b - a) // 2))
else:
    left = a
    right = n - b
    if left <= right:
        ran = b - a
        flag = 0
        ans = 0
        while (ran % 2 != 0):
            b -= 1
            if a != 0:
                a -= 1
            else:
                if flag == 0:
                    flag = 1
                else:
                    a += 1
            ran = b - a
            ans += 1
        print((ans + (ran // 2)))
    else:
        ran = b - a
        flag = 0
        ans = 0
        while (ran % 2 != 0):
            a += 1
            if b != n:
                b += 1
            else:
                if flag == 0:
                    flag = 1
                else:
                    b -= 1
            ran = b - a
            ans += 1
        print((ans + (ran // 2)))

# Optimized solution
n, a, b = list(map(int, input().split()))


if (b - a) % 2 == 0:
    print(((b - a) // 2))
else:
    test = (b - a) // 2
    left = a - 1
    right = n - b
    if left >= right:
        print((n - a - test))
    else:
        print((b - 1 - test))
# Original solution
n,a,b = list(map(int, input().split()))

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

# Optimized solution
n,a,b = list(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))
# Original solution
n,a,b = list(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))

# Optimized solution
n,a,b = list(map(int, input().split()))
print((min(a-1, n-b)+1+(b-a-1)//2 if (b-a)%2!=0 else (b-a)//2))
# Original solution
N, A, B = list(map(int, input().split()))


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

print(ans)

# Optimized solution
def myAnswer(N:int,A:int,B:int) -> int:
   ans = 0
   BN = N - B
   A1 = A - 1
   while True:
      if((B - A) % 2== 0):
         ans += (B - A)//2
         break
      elif(A == 1):
         ans += 1
         B -= 1
      elif(B == N):
         ans += 1
         A += 1
      else:
         if(BN > A1):
            ans +=A1
            B -= A1
            A = 1
         else:
            ans += BN
            A += BN
            B = N
   return ans

def modelAnswer():
   tmp=1
def main():
   N,A,B = list(map(int,input().split()))
   print((myAnswer(N,A,B)))
if __name__ == '__main__':
   main()
# Original solution
N, A, B = list(map(int, input().split()))

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


# Optimized solution
N, A, B = list(map(int, input().split()))

if (B - A) % 2 == 0:
    print(((B - A) // 2))
else:
    # Aが左に到着
    ans1 = 0
    ans1 += A - 1 + 1
    a = 1
    b = B - A
    ans1 += (b - a) // 2

    # Bが右に到着
    ans2 = 0
    ans2 += N - B + 1
    a = A + (N - B + 1)
    b = N
    ans2 += (b - a) // 2

    ans = min(ans1, ans2)
    print(ans)
# Original solution
n, a, b = list(map(int, input().split()))
if (b-a)%2==0:
    print(((b-a)//2))
else:
    print((min(n-b+1+(b-a-1)//2,a+(b-a)//2)))

# Optimized solution
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))
# Original solution
n, a, b = list(map(int, input().split()))
if (b-a)%2 == 0 :
    print(((b-a)//2))
else :
    print(((b-a)//2 + min(a-1,n-b) + 1))


# Optimized solution
n, a, b = list(map(int, input().split()))
print(((b-a)//2 + min(a-1,n-b) + 1 if (b-a)%2 else (b-a)//2))