program sample
  implicit none
  integer :: a,b,c,d,e,i,j
  integer :: s(4)

  read(*,*) a,b,c,d

  if(b<=c)then
     write(*,*) 0
     stop
  else if(d<=a)then
     write(*,*) 0
     stop
  else
     s(1)=a
     s(2)=b
     s(3)=c
     s(4)=d
     do i=1,3
        do j=i+1,4
           if(s(i)>s(j))then
              e=s(j)
              s(j)=s(i)
              s(i)=e
           endif
        enddo
     enddo
     write(*,*) s(3)-s(2)
  endif

end program sample