n,a,b = gets.chomp.split(' ').map(&:to_i)

dist = b - a

if dist % 2 == 0 then
    puts dist /  2
else
    nDis = n - b
    oDis = a - 1
    if nDis < oDis then
        puts nDis+dist
    elsif oDis < nDis then
        puts oDis+dist
    else
        puts nDis+dist
    end
end