#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        s: chars,
        gx: i64, gy: i64
    }
    let fs = split(&s, 'T') .into_iter()
        .map(|v| v.len())
        .collect::<Vec<_>>();
    let mut dpx = vec_md![false;fs.len() + 1;16001];
    let mut dpy = vec_md![false;fs.len() + 1;16001];
    dpx[0][8000] = true;
    dpy[0][8000] = true;
    let mut x = 0;
    let mut y = 0;
    for i in 0..fs.len() {
        let d = fs[i];
        for j in 0..16000 {
            if i % 2 == 0 {
                if j >= d && i != 0 {
                    dpx[x+1][j - d] |= dpx[x][j];
                }
                if j + d < dpx[0].len() {
                    dpx[x+1][j + d] |= dpx[x][j];
                }
            } else {
                if j >= d {
                    dpy[y+1][j - d] |= dpy[y][j];
                }
                if j + d < dpy[0].len() {
                    dpy[y+1][j + d] |= dpy[y][j];
                }
            }
        }
        if i % 2 == 0 {x += 1;}
        else {y += 1;}
    }
    let gxu = (gx + 8000) as usize;
    let gyu = (gy + 8000) as usize;
    println!("{}", if dpx[x][gxu] && dpy[y][gyu] {"Yes"} else {"No"});
}

#[allow(dead_code)]
fn split<T: PartialEq + Clone>(slice: &[T], sep: T) -> Vec<Vec<T>> {
    slice.iter().fold(vec![vec![]], |mut acc, x| {
        if x == &sep {
            acc.push(vec![]);
            acc
        } else {
            let last = acc.len() - 1;
            acc[last].push(x.clone());
            acc
        }
    })
}

Measured memory_bytes: 327292