program example
	implicit none
    
    integer(16) A,B,N
    
    read(*,*) N,A,B
    
    if(mod(B-A,2)==0) then
    
    	write(*,*)  (B-A)/2q0
            
    else
    	if(N-A>B-1) then
        
        	write(*,*) B-1q0
        
        else
        	write(*,*) N-A
        end if
    end if

end program example