import Control.Applicative

solver a b c d = max 0 $ (min b d) - (max a c)

main :: IO ()
main = do
    -- 整数の入力
    [a,b,c,d] <- map read . words <$> getLine :: IO [Int]
    -- 出力
    putStrLn $ show $ solver a b c d

