import Control.Applicative

calc :: Int -> Int -> Int -> Int -> Int
calc a b c d
    | a == c = a ^ (d - b)
    | b == d = b ^ (c - a)
    | otherwise = (calc' (c - 1) d) * d + (calc' c (d - 1)) * c - duplicate
  		where calc' = calc a b
              duplicate = calc' (c - 1) (d - 1) * (c - 1) * (d - 1)

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

