main = do [x,y] <- map read . words <$> getLine [x2,y2] <- map read . words <$> getLine print $ min x y + abs (x-y) + (if x==y && x2==y2 && 0