#include <bits/stdc++.h>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, pair<T1, T2> P)
{
    return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream &operator<<(ostream &s, vector<T> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        if (i > 0)
        {
            s << " ";
        }
        s << P[i];
    }
    return s;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> P)
{
    for (int i = 0; i < P.size(); ++i)
    {
        s << endl
          << P[i];
    }
    return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, set<T> P)
{
    EACH(it, P) { s << "<" << *it << "> "; }
    return s << endl;
}
template <class T1, class T2>
ostream &operator<<(ostream &s, map<T1, T2> P)
{
    EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; }
    return s << endl;
}
template <class T>
void show(vector<T> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cerr << v[i] << " ";
    }
    cerr << "\n";
}
typedef long long ll;

bool dp1[8010][2*8010], dp2[8010][2*8010];
signed main()
{
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = (int)s.size();
    int index = n;
    bool ok = false;
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='T'){
            dp1[0][8001 + i] = true;
            index = i;
            ok = true;
            break;
        }
    }
    if(!ok){
        if(x==n && y==0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        return 0;
    }
    vector<int> v, w;
    int tmp = index;
    bool flag = false;
    for (int i = index+1; i < n; i++)
    {
        
        if(s[i]=='T'){
            if(!flag){
                w.push_back(i - tmp - 1);
            }
            else{
                v.push_back(i - tmp - 1);
            }
            tmp = i;
            flag = 1 - flag;
        }
    }
    if(flag){
        v.push_back(n - tmp - 1);
    }
    else{
        w.push_back(n - tmp - 1);
    }
   // show(v);
   // show(w);
    for (int i = 0; i < v.size(); i++)
    {

        for (int j = -8001; j <= 8001; j++){
            if( 8001 + j - v[i] >=0)
            dp1[i + 1][8001 + j] = dp1[i][8001 + j - v[i]] | dp1[i][8001 + j + v[i]];
            else {
                dp1[i + 1][8001 + j] = dp1[i][8001 + j + v[i]];
            }
        }
    }
    dp2[0][8001] = true;
    for (int i = 0; i < w.size(); i++)
    {
        for (int j = -8001; j <= 8001; j++)
        {
            if (8001 + j - w[i] >= 0)
                dp2[i + 1][8001 + j] = dp2[i][8001 + j - w[i]] | dp2[i][8001 + j + w[i]];
            else
            {
                dp2[i + 1][8001 + j] = dp2[i][8001 + j + w[i]];
            }
        }
    }
    
  /*  for (int i = -10; i < 10; i++)
    {
        cout<<dp2[0][8001 + i] << endl;
    }*/
    cerr << dp1[v.size()][8001 + x] << dp2[w.size()][8001 + y] << endl;
    if (dp1[v.size()][8001 + x] && dp2[w.size()][8001 + y])
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 127360