#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<vector>
#define il inline
#define ll long long
#define INF 0x7fffffff
#define rint register int
using namespace std;
int const N=16001;
vector<int> xoy[2];
int fxy[2];
bool dp[N][N];
il char gc(){
	static char BB[1000000],*S=BB,*T=BB;
	return S==T&&(T=(S=BB)+fread(BB,1,1000000,stdin),S==T)?EOF:*S++;
}
il ll re(){
	ll x=0,w=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
	return x*w;
}
int main(){
	char s[8005];
	scanf("%s",s);
	int xy=0,lon=0;
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='F') lon+=1;
		else{if(lon) xoy[xy].push_back(lon);lon=0,xy^=1;}
	}
	xoy[xy].push_back(lon);
	/*for(int i=0;i<xoy[0].size();i++){
		cout<<xoy[0][i]<<endl;
	}*/
	scanf("%d%d",&fxy[0],&fxy[1]);
	int fl[2]={0};
	for(int k=0;k<=1;k++){
		memset(dp,0,sizeof(dp));
		dp[0][8000]=1;
		int MAX=xoy[k].size();
		for(int i=1;i<=MAX;i++){
			if(s[0]!='T'&&k==0&&i==1&&xoy[k].size()>=1) {dp[1][xoy[k][0]+8000]=1;continue;}
			for(int j=0;j<N;j++){
				 
				if(j-xoy[k][i-1]>=0)dp[i][j]|=dp[i-1][j-xoy[k][i-1]];
				dp[i][j]|=dp[i-1][j+xoy[k][i-1]];
			}
		}
		if(dp[MAX][fxy[k]+8000]) fl[k]=1;
	}
	if(fl[0]&&fl[1]) printf("Yes\n");
	else printf("No\n");
	return 0;
	
	
} 
