#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11


// O(|s|^2)
bool partial_sum(Vec<int>& move, int ask) {
    if ((int)move.size() == 0) {
        if (ask == 0) {
            return true;
        } else {
            return false;
        }
    }

    bool flag;
    int count = 0;
    FOR (i, 0, (int)move.size()) {
        count += move[i];
    }
    if (count == ask) {
        flag = true;
    } else if (count < ask || (count - ask) % 2 == 1) {
        flag = false; 
    } else {
        // 部分和問題を解く
        int target = (count - ask) / 2;
        Vec<Vec<bool> > dp((int)move.size(), Vec<bool>(2 * count + 1, false)); // |s| <= 8000
        dp[0][0] = true;
        dp[0][move[0]] = true;
        FOR (i, 1, (int)move.size()) {
            FOR (j, 0, target + 1) {
                if (dp[i - 1][j] == true) {
                    dp[i][j] = true;
                    if (j - move[i] > 0) {
                        dp[i][j - move[i]] = true;
                    }
                    if (j + move[i] < 2 * count + 1) {
                        dp[i][j + move[i]] = true;
                    }
                }
            }
        }
        flag = dp[(int)move.size() - 1][target];
    }
    return flag;
}

int main(void) {
    string s;
    cin >> s;
    s += 'T';
    int x;
    int y;
    cin >> x >> y;

    Vec<int> move_x;
    Vec<int> move_y;
    // O(|s|)
    int count = 0;
    int times = 0;
    FOR (i, 0, (int)s.length()) {
        if (s[i] == 'T') {
            if (times == 0) {
                x -= count;
            } else if (times % 2 == 0) {
                move_x.push_back(count);
            } else {
                move_y.push_back(count);
            }
            count = 0;
            times++;
        } else {
            count++;
        }
    }

    bool fx = partial_sum(move_x, x);
    bool fy = partial_sum(move_y, y);
    if (fx && fy) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 2304