open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str =
  let len = String.length str in
  let rec f i = if i >= len then [] else str.[i] :: f (i+1) in
  f 0

let lim_width = 16002
let cp = lim_width / 2

let swt ax = match ax with 'X' -> 'Y' | 'Y' -> 'X'

let rec parse ax acc xs =
  match xs with
  | [] -> if acc = 0 then [] else [(acc, ax)]
  | (x::xs') ->
      if x = 'T' then
        if acc = 0 then parse (swt ax) 0 xs'
        else (acc, ax) :: parse (swt ax) 0 xs'
      else parse ax (acc+1) xs'

let () =
  let s0::_ as s = read_line () |> list_of_string in
  let [xp; yp] = read_ints 2 in
  let f_first = s0 = 'F' in
  let steps = parse 'X' 0 s in
  let xs' = steps |> List.filter (fun z -> snd z = 'X') |> List.map fst in
  let (x0, xs) = match xs' with
  | (z::zs) when f_first -> (z, zs)
  | _                    -> (0, xs') in
  let ys = steps |> List.filter (fun z -> snd z = 'Y') |> List.map fst in

  let dp = Array.make lim_width 0 in
  let bak = Array.make lim_width 0 in

  let result = List.for_all (fun (ss, src, dst) ->
    Array.fill dp 0 lim_width 0; dp.(src) <- 1;
    List.iter (fun s ->
      Array.fill bak 0 lim_width 0;
      for_iter_ 0 lim_width (fun i ->
        if dp.(i) = 1 then (
          if i-s >= 0        then bak.(i-s) <- 1;
          if i+s < lim_width then bak.(i+s) <- 1
        ));
      for_iter_ 0 lim_width (fun i -> dp.(i) <- bak.(i));
    ) ss;
    dp.(dst) = 1) [(xs, cp+x0, cp+xp); (ys, cp, cp+yp)] in

  print_endline @@ if result then "Yes" else "No"
