main = do
  (a:b:c:d:_) <- getLine >>= return . (map read) . words :: IO [Int]
  print $ f a b c d
  where
    f a b c d
      | a < c =
        if b < c then
          0
        else if c < b && b < d then
          b-c
        else
          d-c
      | otherwise =
        if d < a then
          0
        else if a < d && d < b then
          d-a
        else
          b-a
