#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  cin >> S;
  ll x, y;
  cin >> x >> y;

  vll x_jump;
  vll y_jump;
  ll x_count = 0;
  ll y_count = 0;
  bool x_flag = true;
  bool init_flag = (S[0]=='F');
  for(ll i=0; i<S.size(); ++i){
    if(S[i]=='T'){
      x_flag = !x_flag;
      if(x_count>0) x_jump.push_back(x_count);
      if(y_count>0) y_jump.push_back(y_count);
      x_count = 0;
      y_count = 0;
    }else if(S[i]=='F'){
      if(x_flag) x_count++;
      else y_count++;
    }
  }
  if(x_count>0) x_jump.push_back(x_count);
  if(y_count>0) y_jump.push_back(y_count);

  vb dpx1(20000, false);
  vb dpy1(20000, false);
  ll SHIFT = 10000;
  dpx1[SHIFT+0] = true;
  dpy1[SHIFT+0] = true;
  for(ll i=0; i<x_jump.size(); ++i){
    vb dpx(20000, false);
    for(ll j=0; j<20000; ++j){
      if(dpx1[j]){
        dpx[j+x_jump[i]]=true;
        if(i==0 && init_flag) continue;
        dpx[j-x_jump[i]]=true;
      }
    }
    dpx1 = dpx;
  }
  for(ll i=0; i<y_jump.size(); ++i){
    vb dpy(20000, false);
    for(ll j=0; j<20000; ++j){
      if(dpy1[j]){
        dpy[j+y_jump[i]]=true;
        dpy[j-y_jump[i]]=true;
      }
    }
    dpy1 = dpy;
  }

  if(dpx1[SHIFT+x] && dpy1[SHIFT+y]){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }


  return 0;
}

Measured memory_bytes: 384