import Data.List
import Data.Array.IO
import Control.Monad

tfSeq [] _ = []
tfSeq (x:xs) n =
  if x == 'F' then
    (length a + 1) : (tfSeq b (n+1))
  else
    if n == 0 then
      0 : (length a) : (tfSeq b (n+1))
    else
      (length a) : (tfSeq b (n+1))
  where
    (a,b) = span (== 'F') xs

distr [] _ = ([], [])
distr (x:xs) n =
  if n == 0 then
    (x:a, b)
  else
    (a, x:b)
  where
    (a,b) = distr xs (mod (n+1) 2)
  
main = do
  s <- getLine
  (x:y:_) <- getLine >>= return . map read . words :: IO [Int]

  let (xs, ys) = distr (tfSeq s 0) 0
  
  xarr <- newArray (-(length s),length s) (-1) :: IO (IOUArray Int Int)
  yarr <- newArray (-(length s),length s) (-1) :: IO (IOUArray Int Int)

  forM_ (zip [1..] xs) $ \(i, x) -> do
    if i == 1 then
      writeArray xarr x i
      else do
      forM_ [-(length s)..length s] $ \j -> do
        r <- readArray xarr j
        when (r == i-1) $ do
          writeArray xarr (j+x) i
          writeArray xarr (j-x) i

  writeArray yarr 0 0
  forM_ (zip [1..] ys) $ \(i, y) -> do
    forM_ [-(length s)..length s] $ \j -> do
      r <- readArray yarr j
      when (r == i-1) $ do
        writeArray yarr (j+y) i
        writeArray yarr (j-y) i  
    
  cx <- readArray xarr x
  cy <- readArray yarr y
  
  putStrLn $ if cx == length xs && cy == length ys then "Yes" else "No"
