#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int x;
    int y;
    cin >> x >> y;
    int count_x = 0;
    bool firstx = true;
    int count_y = 0;
    bool nowx = true;
    bool nowy = false;
    int turned_x = 0;
    int turned_y = 0;
    vector<vector<int> > dpx(4001, vector<int> (16001));
    vector<vector<int> > dpy(4001, vector<int> (16001));
    rep(i,4001){
        rep(j,16001){
            dpx[i][j] = 0;
            dpy[i][j] = 0;
        }
    }
    dpx[0][8000] = 1;
    dpy[0][8000] = 1;
    rep(i,S.size()){
        if (i == S.size() - 1 && S[i] == 'T'){
            if (nowx){
                if (firstx){
                    firstx = false;
                    dpx[1][8000 + count_x]++;
                }
                else{
                    for (ll i = 0; i <= 16000; i++){
                        if (dpx[turned_x][i] >= 1){
                            dpx[turned_x + 1][i + count_x]++;
                            dpx[turned_x + 1][i - count_x]++;
                        }
                    }
                }
                nowx = false;
                nowy = true;
                count_x = 0;
                turned_x++;
            }
            else if (nowy){
                for (ll i = 0; i <= 16000; i++){
                    if (dpy[turned_y][i] >= 1){
                        dpy[turned_y + 1][i + count_y]++;
                        dpy[turned_y + 1][i - count_y]++;
                    }
                }
                nowx = true;
                nowy = false;
                count_y = 0;
                turned_y++;
            }
        }
        else if (i == S.size() - 1 && S[i] == 'F'){
            if (nowx) count_x++;
            if (nowy) count_y++;
            if (nowx){
                if (firstx){
                    firstx = false;
                    dpx[1][8000 + count_x]++;
                }
                else{
                    for (ll i = 0; i <= 16000; i++){
                        if (dpx[turned_x][i] >= 1){
                            dpx[turned_x + 1][i + count_x]++;
                            dpx[turned_x + 1][i - count_x]++;
                        }
                    }
                }
                nowx = false;
                nowy = true;
                count_x = 0;
                turned_x++;
            }
            else if (nowy){
                for (ll i = 0; i <= 16000; i++){
                    if (dpy[turned_y][i] >= 1){
                        dpy[turned_y + 1][i + count_y]++;
                        dpy[turned_y + 1][i - count_y]++;
                    }
                }
                nowx = true;
                nowy = false;
                count_y = 0;
                turned_y++;
            }
        }
        else if (S[i] == 'F'){
            if (nowx) count_x++;
            if (nowy) count_y++;
        }
        else if (S[i] == 'T'){
            if (nowx){
                if (firstx){
                    firstx = false;
                    dpx[1][8000 + count_x]++;
                }
                else{
                    for (ll i = 0; i <= 16000; i++){
                        if (dpx[turned_x][i] >= 1){
                            dpx[turned_x + 1][i + count_x]++;
                            dpx[turned_x + 1][i - count_x]++;
                        }
                    }
                }
                nowx = false;
                nowy = true;
                count_x = 0;
                turned_x++;
            }
            else if (nowy){
                for (ll i = 0; i <= 16000; i++){
                    if (dpy[turned_y][i] >= 1){
                        dpy[turned_y + 1][i + count_y]++;
                        dpy[turned_y + 1][i - count_y]++;
                    }
                }
                nowx = true;
                nowy = false;
                count_y = 0;
                turned_y++;
            }
        }
    }
    if (dpx[turned_x][8000 + x] >= 1 && dpy[turned_y][8000 + y] >= 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 503804