#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pll = pair<ll, ll>;
using pss = pair<string, string>;
using pdd = pair<ld, ld>;
using graph = vector<vector<int>>;

const ll MOD = 1000000007;
const ld EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ex[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ey[8] = {0, 1, 1, 1, 0, -1, -1, -1};

template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }

ll intabs(ll a)
{
    if (a >= 0)
        return a;
    else
        return -a;
}

ll intpow(ll a, ll b, ll p = LLONG_MAX)
{
    ll ret = 1;
    while (b != 0)
    {
        if ((b & 1) == 1)
            ret *= a;
        a *= a;
        if (a >= p)
            a %= p;
        if (ret >= p)
            ret %= p;
        b = b >> 1;
    }
    return ret;
}

int digit(ll a, ll b = 10)
{
    int ret = 0;
    while (a != 0)
    {
        a /= b;
        ret++;
    }
    return ret;
}

ll gcd(ll x, ll y)
{
    while (y != 0)
    {
        ll cnt = x % y;
        x = y;
        y = cnt;
    }
    return x;
}

ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

class UnionFind
{
    vector<int> par, sz;

public:
    UnionFind(int n) : par(n), sz(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            sz[i] = 1;
        }
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
        sz[ry] += sz[rx];
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        return sz[root(x)];
    }
};

int M = 8000;
bool dpx[16001][4001], dpy[16001][4001];

int main()
{
    int i, j, k, cnt;
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    cnt = -1;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] == 'T')
        {
            cnt = i;
            break;
        }
        else
            x--;
    }
    if (cnt == -1)
    {
        if (x == 0)
            printf("Yes");
        else
            printf("No");
        return 0;
    }

    s = s.substr(cnt);
    auto n = s.size();
    bool flg = true;
    int fcnt = 0, tcnt = 0;
    vector<int> vx, vy;
    for (size_t i = 0; i < n; i++)
    {
        if (s[i] == 'F')
            fcnt++;
        else
            tcnt++;
        if (i == n - 1 || (s[i] == 'F' && s[i + 1] == 'T'))
        {
            if (tcnt % 2)
                flg = !flg;
            if (flg)
            {
                vx.push_back(fcnt);
            }
            else
            {
                vy.push_back(fcnt);
            }
            fcnt = 0;
            tcnt = 0;
        }
    }
    for (int i = 0; i <= 2 * M; i++)
    {
        dpx[i][0] = 0;
        dpy[i][0] = 0;
    }
    dpx[M][0] = 1;
    dpy[M][0] = 1;
    for (int j = 0; j < vx.size(); j++)
    {
        for (int i = 0; i <= 2 * M; i++)
        {
            if (i - vx[j] >= 0)
                dpx[i][j + 1] |= dpx[i - vx[j]][j];
            if (i + vx[j] <= 2 * M)
                dpx[i][j + 1] |= dpx[i + vx[j]][j];
        }
    }
    for (int j = 0; j < vy.size(); j++)
    {
        for (int i = 0; i <= 2 * M; i++)
        {
            if (i - vy[j] >= 0)
                dpy[i][j + 1] |= dpy[i - vy[j]][j];
            if (i + vy[j] <= 2 * M)
                dpy[i][j + 1] |= dpy[i + vy[j]][j];
        }
    }
    if (dpx[M + x][vx.size()] && dpy[M + y][vy.size()])
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}


Measured memory_bytes: 125440