program main implicit none integer*8::N,K read *,N,K if(N.lt.K.or.0.ge.K) then print '("0")' else if(N+1.eq.2*K) then print '(i0)',N-1 else print '(i0)',N-2 end if end program main