open Batteries
module Mymap = Map.Make(Int)
module Myset = Set.Make(Int)

let () =
  let s = Scanf.scanf "%s " (fun a -> a) in
  let x,y = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let c_lst = String.to_list s in

  let rec re_x cnt = function
      [] -> x-cnt, []
    | 'F'::tl -> re_x (cnt+1) tl
    | 'T'::tl -> (x-cnt), tl
  in

  let x,c_lst = re_x 0 c_lst in

  let rec aux xl yl cnt is_x = function
      [] -> if is_x then (cnt::xl),yl else xl,(cnt::yl)
    | 'F'::tl -> aux xl yl (cnt+1) is_x tl
    | 'T'::tl -> 
      if is_x = true then aux (cnt::xl) yl 0 (not is_x) tl else
        aux xl (cnt::yl) 0 (not is_x) tl
  in
  let xl,yl = aux [] [] 0 false c_lst in

  let xl = List.filter (fun x -> x <> 0) xl in
  let yl = List.filter (fun x -> x <> 0) yl in

  let xmap = Mymap.empty in
  let xmap = List.fold_left (fun accum x -> Mymap.modify_opt x (fun v_opt -> match v_opt with
        Some v -> Some (v + 1)
      | None -> Some 1
    ) accum) xmap xl
  in
  let xmap_assoc = Mymap.bindings xmap in

  let make_seq n c =
    let set = Myset.empty in
    let pos = List.init (c) (fun i -> let i = i+1 in i*n) in
    let neg = List.map (fun x -> -x) pos in

    let tmp_lst = if c mod 2 = 0 then (0 :: (neg @ pos)) else (neg @ pos) in

    List.fold_left (fun set el -> Myset.add el set) set tmp_lst
  in

  let xseq_lst = List.map (fun (x,y) -> make_seq x y) xmap_assoc in

  let rec foo l1 l2 res = match l1 with
      [] -> res
    | hd::tl -> 
      let res = (List.fold_left (fun set x -> Myset.add (hd*x) set) res l2) in
      foo tl l2 res
  in
  let x_ans = 
    if xseq_lst = [] then (Myset.add 0 Myset.empty) else
    List.fold_left (fun set1 set2 -> 
      let elements1 = Myset.elements set1 in
      let elements2 = Myset.elements set2 in
      foo elements1 elements2 Myset.empty
    ) (Myset.add 1 Myset.empty) xseq_lst
  in

  let ymap = Mymap.empty in
  let ymap = List.fold_left (fun accum x -> Mymap.modify_opt x (fun v_opt -> match v_opt with
        Some v -> Some (v + 1)
      | None -> Some 1
    ) accum) ymap yl
  in
  let ymap_assoc = Mymap.bindings ymap in

  let yseq_lst = List.map (fun (x,y) -> make_seq x y) ymap_assoc in

  let y_ans = 
    if yseq_lst = [] then (Myset.add 0 Myset.empty) else
      List.fold_left (fun set1 set2 -> 
          let elements1 = Myset.elements set1 in
          let elements2 = Myset.elements set2 in
          foo elements1 elements2 Myset.empty
        ) (Myset.add 1 Myset.empty) yseq_lst
  in

  Printf.printf "%s\n" @@
  if (Myset.mem x x_ans) && (Myset.mem y y_ans) then "Yes" else "No"

