main::IO()
main=do
  s<-getLine
  let a:b:c:d:[]=map read (words s)
  print (if (d<=a) || (b<=c)
          then 0
          else if a<=c && d<=b
                then (d-c)
                else if c<=a && b<=d
                      then (b-a)
                      else if a<=c && b<=d
                            then (b-c)
                            else if c<=a && d<=b
                                  then (d-a)
                                  else 0 )