#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#define ll long long
#define pr(a) cerr<<#a<<"="<<a<<endl
#define pri(a,lo) {cerr<<#a<<"={";for (int ol=0;ol<=lo;ol++)cerr<<a[ol]<<",";cout<<"}"<<endl;}
using namespace std;
#define N 1000100
map<int,int> a[3],b;
map<int,int>::iterator it;
char ch[N];
int i,o,p,t;
int main()
{
	scanf("%s",ch);
	int l=(int)strlen(ch);
	a[0][0]=a[1][0]=1;
	ch[l]='T',l++;int f=1;
	for (i=0;i<l;i++)
	{
		if (ch[i]=='T')
		{
			//pr(t);pr(o);
			b.clear();
			for (it=a[o].begin();it!=a[o].end();it++)
			{
				int x=(*it).first;
				b[x+t]=1;
				if (f==0) b[x-t]=1;
			}
			a[o]=b;
			t=0;
			o^=1;
			f=0;
		}
		else t++;
	}
	scanf("%d %d",&o,&p);
	if (a[0][o]==1&&a[1][p]==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}