import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [a, b, c, k] <- fmap read . words <$> getLine :: IO [Int]
    if even k
        then print (a - b)
        else print (b - a)