main :: IO () main = interact $ show . solve . map read . words solve :: [Int] -> Int solve [a, b, c, d] = length $ filter (\(x, y) -> x /= y) [(x, y) | x <- [a .. b], y <- [c .. d]]