open Batteries

type rot_t = Left | Down | Right | Up

let rotate_left = function
  | Left -> Down
  | Down -> Right
  | Right -> Up
  | Up -> Left

let rotate_right = function
  | Left -> Up
  | Up -> Right
  | Right -> Down
  | Down -> Left

let move (x, y) = function
  | Left -> (x-1, y)
  | Down -> (x, y-1)
  | Right -> (x+1, y)
  | Up -> (x, y+1)

let solve s x y =
  let instrs = String.to_list s in
  let rec go (ix, iy) rot m = function
    | [] -> (ix = x) && (iy = y)
    | 'F' :: rest ->
      if (abs (x - ix) + abs (y - iy)) > m then false
      else go (move (ix, iy) rot) rot (m-1) rest
    | 'T' :: rest ->
      (go (ix, iy) (rotate_left rot) (m-1) rest)
      || (go (ix, iy) (rotate_right rot) (m-1) rest)
  in
  print_string @@ if go (0, 0) Right (String.length s) instrs then "Yes" else "No"

let () = Scanf.scanf "%s\n%d %d" solve