main :: IO ()
main = do
  line <- getLine
  let [s, t] = words line
  [numS, numT] <- getInts
  name <- getLine
  putStrLn $ (show $ getBallNum s numS name) ++ " " ++ (show $ getBallNum t numT name)

getBallNum :: String -> Int -> String -> Int
getBallNum name count removeName
  | name == removeName = count - 1
  | otherwise = count

getInts = do
  x <- getLine
  let y = (map $ read) $ words x :: [Int]
  return y
