{-# LANGUAGE FlexibleInstances #-}
 
-- StdIn
 
class In a where stdin :: IO a
instance In [Int] where stdin = map read . words <$> getLine
 
solve :: Int -> Int -> Int -> Int -> Int
solve a b c d = max 0 $ (min b d) - (max a c)

main :: IO ()
main = do
  [a, b, c, d] <- stdin
  print $ solve a b c d
  --print $ solve 0 75 25 100
  --print $ solve 0 33 66 99
  --print $ solve 10 90 20 80
