main :: IO()
main = do
    [a,b,c,d] <- map read . words <$> getLine
    print $ getsolve (a,b) (c,d)
    
getsolve :: (Int, Int) -> (Int, Int) -> Int
getsolve (a,b) (c,d)
    | start < end		= end - start 
    | otherwise			= 0
    where start = max a c
          end = min b d