module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [a, b, c, d] <- fmap read . words <$> getLine :: IO [Int]
    let x = max a c
    let y = min b d
    if y - x >= 0
        then print (y - x)
        else print 0