#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int n, x, y, z, s, e[2], c[2];
vector<int> b[2];
string a;
bool v[2][8005][8005];
bool f(int p, int q, int z) {
	if (q > e[z]) return false;
	if (q == e[z]) return true;
	if (v[z][p][q]) return false;
	if (p == b[z].size()) return false;
	v[z][p][q] = true;
	return (f(p + 1, q, z) | f(p + 1, q + b[z][p], z));
}
int main()
{
	int i;
	cin >> a;
	cin >> x >> y;
	z = 0;
	for (i =0; i < a.size(); i++) {
		if (a[i] == 'F') s++;
		else {
			b[z].push_back(s);
			c[z] += s;
			z = 1 - z;
			s = 0;
		}
	}
	b[z].push_back(s);
	c[z] += s;
	if ((c[0] + x) % 2 || (c[1] + y) % 2) {
		cout << "No";
		return 0;
	}
	e[0] = (c[0] + x) / 2;
	e[1] = (c[1] + y) / 2;
	if (f(1, b[0][0], 0) && f(0, 0, 1)) cout << "Yes";
	else cout << "No";
    return 0;
}
