      program main
      integer a,b,c,d,s,e
      read(*,*) a,b,c,d
      if (a .gt. c) then
            s = a
      else
            s = c
      end if
      if (b .lt. d) then
            e = b
      else
            e = d
      end if
      if (s .lt. e) then
            write(*,*) e-s
      else
            write(*,*) 0
      end if
      end