import Data.List (intersect)

main = do
    [a,b,c,d] <- fmap (read :: String -> Int) . words <$> getLine
    printTime $ length $ intersect [a..b] [c..d]
    where
        printTime 0 = print 0
        printTime n = print $ n-1