#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

bool canMake(vector<int>& vs, int goal) {
    if (vs.empty()) {
        return goal == 0;
    }
    set<int> tmp;
    if (vs[0] == goal) return true;
    tmp.insert(vs[0]);
    tmp.insert(0);
    FOR(i, 1, SIZE(vs)) {
        set<int> tmp2;
        for (auto t: tmp) {
            auto val = t + vs[i];
            if (val == goal) return true;
            if (val < goal) tmp2.insert(val);
        }
        tmp = tmp2;
    }
    return tmp.count(goal);
}

bool can_move(deque<int>& vs, int goal, int ini_pos) {
    set<int> tmp;
    tmp.insert(ini_pos);
    for(auto v: vs) {
        set<int> tmp2;
        for (auto t: tmp) {
            tmp2.insert(t + v);
            tmp2.insert(t - v);
        }
        tmp = tmp2;
    }
    return tmp.count(goal);
}


bool solve_fail(string s, int x, int y) {
    bool ini = true;
    bool xyFlag = true;
    vector<int> xs;
    vector<int> ys;
    int len = 0;
    for (auto ch : s) {
        if (ch == 'F') {
            if (ini) {
                --x;
            }
            else {
                ++len;
            }
        }
        else {
            if (ini) {
                ini = false;
            }
            else {
                if (len != 0) {
                    if (xyFlag) xs.pb(len);
                    else ys.pb(len);
                }
            }
            xyFlag = !xyFlag;
            len = 0;
        }
    }
    if (s.back() == 'F') {
        if (!ini) {
            if (xyFlag) xs.pb(len);
            else ys.pb(len);
        }
    }

    x = abs(x);
    y = abs(y);
    auto xSum = accumulate(ALL(xs), 0);
    auto ySum = accumulate(ALL(ys), 0);
    if ((xSum + x) % 2) return false;
    if ((ySum + y) % 2) return false;
    return canMake(xs, (xSum + x) / 2) && canMake(ys, (ySum + y) / 2);
}

bool solve(string s, int x, int y) {
    bool xyFlag = true;
    deque<int> xs;
    deque<int> ys;
    int len = 0;
    for (auto ch : s) {
        if (ch == 'F') {
            ++len;
        }
        else {
            if (len != 0) {
                if (xyFlag) xs.pb(len);
                else ys.pb(len);
            }
            xyFlag = !xyFlag;
            len = 0;
        }
    }
    if (s.back() == 'F') {
        if (xyFlag) xs.pb(len);
        else ys.pb(len);
    }

    int xPos = 0;
    if (SIZE(xs) > 0 && s[0] == 'F') {
        xPos = xs[0];
        xs.pop_front();
    }

    return can_move(xs, x, xPos) && can_move(ys, y, 0);
}


int main(void)
{
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;

    //assert(solve("FFFFF", 5, 0) == true);
    //assert(solve("F", 1, 0) == true);
    //assert(solve("F", 0, 0) == false);
    //assert(solve("T", 0, 0) == true);
    //assert(solve("TTTTTT", 0, 0) == true);
    //assert(solve("TTTTTT", 0, 1) == false);
    //assert(solve("TTTTTT", 1, 0) == false);
    //assert(solve("T", 1, 0) == false);
    //assert(solve("TFF", 0, 2) == true);
    //assert(solve("TFF", 0, -2) == true);
    //assert(solve("TFF", -1, -2) == false);
    //assert(solve("FTFFTFFFTFFF", 4, -5) == true);
    //assert(solve("FTFFTFFFTFFF", 4, -1) == true);
    //assert(solve("FTFFTFFFTFFF", 4, 1) == true);
    //assert(solve("FTFFTFFFTFFF", 4, 5) == true);
    //assert(solve("FTFFTFFFTFFF", -2, -5) == true);
    //assert(solve("FTFFTFFFTFFF", -2, -1) == true);
    //assert(solve("FTFFTFFFTFFF", -2, 1) == true);
    //assert(solve("FTFFTFFFTFFF", -2, 5) == true);
    //assert(solve("FTFFTFFFTFFF", 3, -5) == false);
    //assert(solve("FTFFTFFFTFFF", 3, -1) == false);
    //assert(solve("FTFFTFFFTFFF", 3, 1) == false);
    //assert(solve("FTFFTFFFTFFF", 3, 5) == false);
    //assert(solve("FTFFTFFFTFFF", -3, -5) == false);
    //assert(solve("FTFFTFFFTFFF", -3, -1) == false);
    //assert(solve("FTFFTFFFTFFF", -3, 1) == false);
    //assert(solve("FTFFTFFFTFFF", -3, 5) == false);

    //for (auto i : vector<int>{ -6, -2, 2, 6 }) {
    //    for (auto j : vector<int>{ -4, -2, 2, 4 }) {
    //        assert(solve("TFTFFTFFFTFFFF", i, j) == true);
    //        assert(solve("TFTFFTFFFTFFFFT", i, j) == true);
    //        assert(solve("TFTFFTFFFTFFFFTT", i, j) == true);
    //        assert(solve("TFTFFTFFFTTTFFFFTT", i, j) == true);
    //    }
    //}

    //assert(solve("FFTFF", 2, 2) == true);
    //assert(solve("FFTFF", 2, -2) == true);


    if (solve(s, x, y)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640