Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A
    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                A-=A-1
                B-=A-1
                n+=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                B+=N-1
                A+=N-1
                n+=N-1
            return f(A,B,n)

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



Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
def f(A,B,n) :
    judge=B-A
    if judge % 2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A>1 :
                A-=A-1
            else:
                pass
            B-=A-1
            n+=A-1
            return f(A,B,n)
        else :
            if B<N :
                B+=N-1
            else :
                pass
            A+=N-1
            n+=N-1
            return f(A,B,n)

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



Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=abs(B-A)
    if judge%2==0 :
        n+=judge//2
        return(n)
    else :
        if abs(1-A) < abs(N-B) :
            if A>1 :
                A-=1
                B-=1
                n+=1
            else:
                A=A
                B-=1
                n+=1
            return f(A,B,n)
        else :
            if B<N :
                B+=1
                A+=1
                n+=1
            else :
                B=B
                A+=1
                n+=1
            return f(A,B,n)

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

print(f(A,B,0))

Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n):
    judge=abs(B-A)
    if judge%2==0:
        n+=judge//2
        return(n)
    else:
        if abs(1-A) < abs(N-B) :
            if A>1:
                A-=1
                B-=1
                n+=1
            else:
                B-=1
                n+=1
            return f(A,B,n)
        else:
            if B<N:
                B+=1
                A+=1
                n+=1
            else:
                A+=1
                n+=1
            return f(A,B,n)


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

print(f(A,B,0))

Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n):
    judge=abs(B-A)
    if judge%2==0:
        n+=judge//2
        return(n)
    else:
        if 1-A < N-B :
            if A>1:
                A-=1
                B-=1
                n+=1
            else:
                B-=1
                n+=1
            return f(A,B,n)
        else:
            if B<N:
                B+=1
                A+=1
                n+=1
            else:
                A+=1
                n+=1
            return f(A,B,n)



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

print(f(A,B,0))

Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n):
    judge=abs(B-A)
    if judge%2==0:
        n+=judge//2
        return(n)
    else:
        if 1-A < N-B :
            if A>1:
                A-=1
                B-=1
                n+=1
            else:
                B-=1
                n+=1
            return f(A,B,n)
        else:
            if B<N:
                B+=1
                A+=1
                n+=1
            else:
                A+=1
                n+=1
            return f(A,B,n)



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

print(f(A,B,0))

Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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

Buggy python submission (verdict: Runtime Error):
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n):
    judge=abs(B-A)
    if judge%2==0:
        n+=judge//2
        return(n)
    else:
        if 1-A < N-B :
            if A>2:
                A-=1
                B-=1
                n+=1
            else:
                B-=1
                n+=1
            return f(A,B,n)
        else:
            if B<N:
                B+=1
                A+=1
                n+=1
            else:
                A+=1
                n+=1
            return f(A,B,n)



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

print(f(A,B,0))

Fixed submission:
# AtCoder Grand Contest 041
# A - Table Tennis Training

def f(A,B,n) :
    judge=B-A

    if judge%2==0 :
        n+=judge//2
        return(n)

    else :
        if abs(A-1) < abs(N-B) :
            if A==1 :
                A=A
                B-=1
                n+=1
            else:
                B-=A-1
                n+=A-1
                A-=A-1
            return f(A,B,n)
        else :
            if B==N :
                B=B
                A+=1
                n+=1
            else :
                A+=abs(N-B)
                n+=abs(N-B)
                B+=abs(N-B)
            return f(A,B,n)

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