#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
ll dpx[4101][16001];
ll dpy[4101][16001];
int main(){
  string s;
  cin>>s;
  ll x,y; cin>>x>>y;
  ll a[8000]={};
  ll b[8000]={};
  ll aa = 0;
  ll bb = 0;
  ll o = 0;
  for(ll i=0; i<(ll)s.size(); i++){
    if(s.at(i)=='T'){
      o++;
      continue;}
    ll ca = 0;
    while(1){
      if(i==s.size())break;
      if(s.at(i)=='F'){
        ca++;
        i++;}
      else break;}
    i--;
    if(o%2==0){
      a[aa]=ca;
      aa++;}
    else{
      b[bb]=ca;
      bb++;}
  }
  if(s.at(0)=='F'){
  dpx[1][8000+a[0]]=1;
  dpy[0][8000]=1;
  repl(i,1,aa){
      rep(j,16000){
        if(j-a[i]<0){
          if(j+a[i]>16000){
            continue;}
          else{
            dpx[i+1][j]=dpx[i][j+a[i]];}
        }
        else{
          if(j+a[i]>16000){
            dpx[i+1][j]=dpx[i][j-a[i]];}
          else{
            dpx[i+1][j]=max(dpx[i][j-a[i]],dpx[i][j+a[i]]);}
        }
      }
    }
  }
  else{
    dpx[0][8000]=1;
  dpy[0][8000]=1;
  repl(i,0,aa){
      rep(j,16000){
        if(j-a[i]<0){
          if(j+a[i]>16000){
            continue;}
          else{
            dpx[i+1][j]=dpx[i][j+a[i]];}
        }
        else{
          if(j+a[i]>16000){
            dpx[i+1][j]=dpx[i][j-a[i]];}
          else{
            dpx[i+1][j]=max(dpx[i][j-a[i]],dpx[i][j+a[i]]);}
        }
      }
    }
  }
  rep(i,bb){
      rep(j,16000){
        if(j-b[i]<0){
          if(j+b[i]>16000){
            continue;}
          else{
            dpy[i+1][j]=dpy[i][j+b[i]];}
        }
        else{
          if(j+b[i]>16000){
            dpy[i+1][j]=dpy[i][j-b[i]];}
          else{
            dpy[i+1][j]=max(dpy[i][j-b[i]],dpy[i][j+b[i]]);}
        }
      }
    }
  if(dpx[aa][8000+x]==1&&dpy[bb][8000+y]==1){
    cout << "Yes" << endl;}
  else cout << "No" << endl;}


Measured memory_bytes: 503560