solve [a,b,c,d] = length $ filter f [ (x, y) | x <- [a..b], y <- [c..d] ] where f (x, y) = x /= y main = getLine >>= print . solve . map (read :: String -> Int) . words