module Main where

import Data.List

main :: IO()
main = do
  [a,b,c,d] <- map read . words <$> getLine
  print $ solve a b c d

solve :: Int -> Int -> Int -> Int -> Int
solve a b c d = case length (intersect [a..b] [c..d]) - 1 of
  result
    | result <= 0   -> 0
    | otherwise     -> result
