strip :: [a] -> a
strip [x] = x

main = do
  ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
  let r = strip $ head ns
  let g = strip $ last ns
  putStrLn $ show $ (-r + 2 * g)