import math
n, i, j = map(int, input().split())


def solution():
    delta = abs(j - i)
    if delta == 1:
        return 0
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


def solution2():
    delta = abs(j - i)
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


print(solution2())

a952253f93f9548bc6717f08235e6a2c7c49c6f0
<mask token>


def solution():
    delta = abs(j - i)
    if delta == 1:
        return 0
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


def solution2():
    delta = abs(j - i)
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


<mask token>

<mask token>


def solution():
    delta = abs(j - i)
    if delta == 1:
        return 0
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


def solution2():
    delta = abs(j - i)
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


print(solution2())

<mask token>
n, i, j = map(int, input().split())


def solution():
    delta = abs(j - i)
    if delta == 1:
        return 0
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


def solution2():
    delta = abs(j - i)
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


print(solution2())

import math
n, i, j = map(int, input().split())


def solution():
    delta = abs(j - i)
    if delta == 1:
        return 0
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


def solution2():
    delta = abs(j - i)
    if delta <= math.floor(n / 2):
        return delta - 1
    return n - delta - 1


print(solution2())
