let rec interleave xs ys =
  match xs, ys with
  | [], _ -> ys
  | _, [] -> xs
  | x :: xs, y :: ys -> x :: y :: interleave xs ys

module IntPairSet = Set.Make (struct
  type t = int * int
  let compare = compare
end)

let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () =
  let s = Scanf.scanf "%s\n" (fun s -> s) in
  let x, y = Scanf.scanf "%d %d\n" (fun x y -> x, y) in
  array_of_string s
  |> Array.fold_left (fun (acc, curr) c ->
      match c with
      | 'F' -> (acc, curr + 1)
      | 'T' -> (curr :: acc, 0)) ([], 0)
  |> (fun (acc, curr) -> List.rev (curr :: acc))
  |> List.fold_left (fun (b, (xs, ys)) x ->
      (not b, if b then (x :: xs, ys) else (xs, x :: ys))) (true, ([], []))
  |> (fun (_, (xs, ys)) ->
      interleave (List.sort compare xs) (List.sort compare ys))
  |> (fun s -> List.fold_left (fun (m, s) n ->
      (m - n, IntPairSet.fold (fun (x, y) s ->
        [(-y, x + n); (y, -x - n)]
        |> List.filter (fun (x, y) -> abs x + abs y <= m - n)
        |> List.fold_left (fun s xy -> IntPairSet.add xy s) s) s IntPairSet.empty))
      (List.fold_left ( + ) 0 s, IntPairSet.singleton (-x, -y)) s)
  |> snd
  |> IntPairSet.exists (fun (x, y) -> x = 0 && y = 0)
  |> (function true -> "Yes" | false -> "No")
  |> print_endline