//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int x, y, n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n=s.size();
    bool dp[n+1][16001];
    vector<int> count;
    int temp=0;
    for(int i=0;i<n;i++){
        if(s[i]=='F'){
            temp++;
            if(i==n-1){
                count.push_back(temp);
            }
        }
        else{
            count.push_back(temp);
            temp=0;
        }
    }
    /*
    for(int i=0;i<count.size();i++){
        cout<<count[i]<<" ";
    }
    cout<<"\n";
    */
    for (int i = 0; i <= n; i++)
    {
        for(int j=0;j<=16000;j++){
            dp[i][j]=false;
        }
    }
    cin>>x>>y;
    dp[0][8000]=true;
    bool check=true;
    int k=0;
    for(int i=0;i<n;i++){
        if(i==n-1&&s[i]=='F'&&check){
           for(int j=0;j<=16000;j++){
                if(dp[i][j]){
                    dp[i+1][j+count[k]]=true;
                    if(k!=0)
                    dp[i+1][j-count[k]]=true;
                    //cout<<i<<" "<<j<<"\n";
                    }
                }
                k++;
                continue; 
        }
        if(s[i]=='T'){
            check=!check;
            if(!check){
                for(int j=0;j<=16000;j++){
                if(dp[i][j]){
                    dp[i+1][j+count[k]]=true;
                    if(k!=0)
                    dp[i+1][j-count[k]]=true;
                    //cout<<i<<" "<<j<<"\n";
                    }
                }
                k++;
                continue;
            }
            k++;
        }
        for(int j=0;j<=16000;j++){
            if(dp[i][j])
            dp[i+1][j]=true;
        }
    }
    if(!dp[n][8000+x])return no,0;
    for (int i = 0; i <= n; i++)
    {
        for(int j=0;j<=16000;j++){
            dp[i][j]=false;
        }
    }
    dp[0][8000]=true;
    check=false;
    k=0;
    for(int i=0;i<n;i++){
        //cout<<k<<"\n";
        if(i==n-1&&s[i]=='F'&&check){
           for(int j=0;j<=16000;j++){
                if(dp[i][j]){
                    dp[i+1][j+count[k]]=true;
                    dp[i+1][j-count[k]]=true;
                    //cout<<i<<" "<<j<<"\n";
                    }
                }
                k++;
                continue; 
        }
        if(s[i]=='T'){
            check=!check;
            if(!check){
                for(int j=0;j<=16000;j++){
                if(dp[i][j]){
                    dp[i+1][j+count[k]]=true;
                    dp[i+1][j-count[k]]=true;
                    //cout<<i<<" "<<j<<"\n";
                    }
                }
                k++;
                continue;
            }
            k++;
        }
        for(int j=0;j<=16000;j++){
            if(dp[i][j])
            dp[i+1][j]=true;
        }
    }
    if(!dp[n][8000+y])return no,0;
    yes;
}



Measured memory_bytes: 125312