import Data.List

solve :: Int -> Int -> Int -> Int -> Int
solve a b c d
  | b <= c = 0
  | d <= a = 0
  | True = y - x
    where
      _:x:y:_ = sort [a, b, c, d]
      
main :: IO ()
main = do
  a:b:c:d:_ <- fmap (\x -> read x :: Int) <$> words <$> getLine
  print $ solve a b c d