import sys

from collections import *

import heapq

import math

import bisect

from itertools import permutations,accumulate,combinations,product

from fractions import gcd

def input():

    return sys.stdin.readline()[:-1]

mod=pow(10,9)+7



s=eval(input())

x,y=list(map(int,input().split()))

lst=[[],[]]

cnt=0

tmp=0

for i in range(len(s)):

    if s[i]=="F":

        tmp+=1

    else:

        if cnt==0:

            x-=tmp

        else:

            if tmp!=0:

                lst[cnt%2].append(tmp)

        tmp=0

        cnt+=1

if cnt==0:

    x-=tmp

elif tmp!=0:

    lst[cnt%2].append(tmp)



sumx=sum(lst[0])

sumy=sum(lst[1])

# print(x,sumx)

if sumx<x or x<-sumx:

    print("No")

    exit()

if sumy<y or y<-sumy:

    print("No")

    exit()

dpx=[[0]*(sumx*2+1) for i in range(len(lst[0])+1)]

dpy=[[0]*(sumy*2+1) for i in range(len(lst[1])+1)]

dpx[0][sumx]=1

dpy[0][sumy]=1



for i in range(len(lst[0])):

    for j in range(sumx*2+1):

        if dpx[i][j]!=0:

            dpx[i+1][j+lst[0][i]]+=1

            dpx[i+1][j-lst[0][i]]+=1



for i in range(len(lst[1])):

    for j in range(sumy*2+1):

        if dpy[i][j]!=0:

            dpy[i+1][j+lst[1][i]]+=1

            dpy[i+1][j-lst[1][i]]+=1



# print(dpx)

# print(dpy)

if dpx[len(lst[0])][sumx+x]!=0 and dpy[len(lst[1])][sumy+y]!=0:

    print("Yes")

else:

    print("No")
import bisect

import copy

import heapq

import math

import sys

from collections import *

from itertools import accumulate, combinations, permutations, product

# from math import gcd

def input():

    return sys.stdin.readline()[:-1]

def ruiseki(lst):

    return [0]+list(accumulate(lst))

mod=pow(10,9)+7

al=[chr(ord('a') + i) for i in range(26)]

direction=[[1,0],[0,1],[-1,0],[0,-1]]



s=eval(input())

x,y=list(map(int,input().split()))

tate,yoko=[],[]

kaisi=0

tmp=0

flag=1

for i in range(len(s)):

    if s[i]=="F":

        tmp+=1

    elif s[i]=="T":

        if kaisi==0:

            kaisi=1

            x-=tmp

        elif flag==0:

            flag=1

            yoko.append(tmp)

        else:

            flag=0

            tate.append(tmp)

        tmp=0





if kaisi==0:

    kaisi=1

    x-=tmp

elif flag==0:

    flag=1

    yoko.append(tmp)

else:

    flag=0

    tate.append(tmp)



if sum(yoko)==0 and sum(tate)==0:

    if x==0 and y==0:

        print("Yes")

    else:

        print("No")

    quit()

# print(yoko,tate)



if abs(x)>sum(yoko) or abs(y)>sum(tate):

    print("No")

    quit()

yokolst=[[0]*(sum(yoko)*2+1) for i in range(len(yoko)+1)]

tatelst=[[0]*(sum(tate)*2+1) for i in range(len(tate)+1)]

yokolst[0][sum(yoko)]=1

tatelst[0][sum(tate)]=1

# print(yokolst)

# print(tatelst)

for i in range(len(tate)):

    for j in range(len(tatelst[0])):

        if tatelst[i][j]==1:

            tatelst[i+1][j+tate[i]]=1

            tatelst[i+1][j-tate[i]]=1





for i in range(len(yoko)):

    for j in range(len(yokolst[0])):

        if yokolst[i][j]==1:

            yokolst[i+1][j+yoko[i]]=1

            yokolst[i+1][j-yoko[i]]=1





# print(yokolst)

# print(tatelst)



if tatelst[-1][sum(tate)+y]==1 and yokolst[-1][sum(yoko)+x]==1:

    print("Yes")

else:

    print("No")
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations, accumulate, combinations, product
from fractions import gcd


def input():
    return sys.stdin.readline()[:-1]


mod = pow(10, 9) + 7
s = eval(input())
x, y = list(map(int, input().split()))
lst = [[], []]
cnt = 0
tmp = 0
for i in range(len(s)):
    if s[i] == "F":
        tmp += 1
    else:
        if cnt == 0:
            x -= tmp
        else:
            if tmp != 0:
                lst[cnt % 2].append(tmp)
        tmp = 0
        cnt += 1
if cnt == 0:
    x -= tmp
elif tmp != 0:
    lst[cnt % 2].append(tmp)
sumx = sum(lst[0])
sumy = sum(lst[1])
# print(x,sumx)
if sumx < x or x < -sumx:
    print("No")
    exit()
if sumy < y or y < -sumy:
    print("No")
    exit()
dpx = [[0] * (sumx * 2 + 1) for i in range(len(lst[0]) + 1)]
dpy = [[0] * (sumy * 2 + 1) for i in range(len(lst[1]) + 1)]
dpx[0][sumx] = 1
dpy[0][sumy] = 1
for i in range(len(lst[0])):
    for j in range(sumx * 2 + 1):
        if dpx[i][j] != 0:
            dpx[i + 1][j + lst[0][i]] += 1
            dpx[i + 1][j - lst[0][i]] += 1
for i in range(len(lst[1])):
    for j in range(sumy * 2 + 1):
        if dpy[i][j] != 0:
            dpy[i + 1][j + lst[1][i]] += 1
            dpy[i + 1][j - lst[1][i]] += 1
# print(dpx)
# print(dpy)
if dpx[len(lst[0])][sumx + x] != 0 and dpy[len(lst[1])][sumy + y] != 0:
    print("Yes")
else:
    print("No")

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product

# from math import gcd
def input():
    return sys.stdin.readline()[:-1]


def ruiseki(lst):
    return [0] + list(accumulate(lst))


mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
s = eval(input())
x, y = list(map(int, input().split()))
tate, yoko = [], []
kaisi = 0
tmp = 0
flag = 1
for i in range(len(s)):
    if s[i] == "F":
        tmp += 1
    elif s[i] == "T":
        if kaisi == 0:
            kaisi = 1
            x -= tmp
        elif flag == 0:
            flag = 1
            yoko.append(tmp)
        else:
            flag = 0
            tate.append(tmp)
        tmp = 0
if kaisi == 0:
    kaisi = 1
    x -= tmp
elif flag == 0:
    flag = 1
    yoko.append(tmp)
else:
    flag = 0
    tate.append(tmp)
if sum(yoko) == 0 and sum(tate) == 0:
    if x == 0 and y == 0:
        print("Yes")
    else:
        print("No")
    quit()
# print(yoko,tate)
if abs(x) > sum(yoko) or abs(y) > sum(tate):
    print("No")
    quit()
yokolst = [[0] * (sum(yoko) * 2 + 1) for i in range(len(yoko) + 1)]
tatelst = [[0] * (sum(tate) * 2 + 1) for i in range(len(tate) + 1)]
yokolst[0][sum(yoko)] = 1
tatelst[0][sum(tate)] = 1
# print(yokolst)
# print(tatelst)
for i in range(len(tate)):
    for j in range(len(tatelst[0])):
        if tatelst[i][j] == 1:
            tatelst[i + 1][j + tate[i]] = 1
            tatelst[i + 1][j - tate[i]] = 1
for i in range(len(yoko)):
    for j in range(len(yokolst[0])):
        if yokolst[i][j] == 1:
            yokolst[i + 1][j + yoko[i]] = 1
            yokolst[i + 1][j - yoko[i]] = 1
# print(yokolst)
# print(tatelst)
if tatelst[-1][sum(tate) + y] == 1 and yokolst[-1][sum(yoko) + x] == 1:
    print("Yes")
else:
    print("No")

+import bisect +import copy +import heapq +import math -import heapq -import math -import bisect -from itertools import permutations, accumulate, combinations, product -from fractions import gcd +from itertools import accumulate, combinations, permutations, product - +# from math import gcd +def ruiseki(lst): +    return [0] + list(accumulate(lst)) + + +al = [chr(ord("a") + i) for i in range(26)] +direction = [[1, 0], [0, 1], [-1, 0], [0, -1]] -lst = [[], []] -cnt = 0 +tate, yoko = [], [] +kaisi = 0 +flag = 1 +    elif s[i] == "T": +        if kaisi == 0: +            kaisi = 1 +            x -= tmp +        elif flag == 0: +            flag = 1 +            yoko.append(tmp) +        else: +            flag = 0 +            tate.append(tmp) +        tmp = 0 +if kaisi == 0: +    kaisi = 1 +    x -= tmp +elif flag == 0: +    flag = 1 +    yoko.append(tmp) +else: +    flag = 0 +    tate.append(tmp) +if sum(yoko) == 0 and sum(tate) == 0: +    if x == 0 and y == 0: +        print("Yes") -        if cnt == 0: -            x -= tmp -        else: -            if tmp != 0: -                lst[cnt % 2].append(tmp) -        tmp = 0 -        cnt += 1 -if cnt == 0: -    x -= tmp -elif tmp != 0: -    lst[cnt % 2].append(tmp) -sumx = sum(lst[0]) -sumy = sum(lst[1]) -# print(x,sumx) -if sumx < x or x < -sumx: +        print("No") +    quit() +# print(yoko,tate) +if abs(x) > sum(yoko) or abs(y) > sum(tate): -    exit() -if sumy < y or y < -sumy: -    print("No") -    exit() -dpx = [[0] * (sumx * 2 + 1) for i in range(len(lst[0]) + 1)] -dpy = [[0] * (sumy * 2 + 1) for i in range(len(lst[1]) + 1)] -dpx[0][sumx] = 1 -dpy[0][sumy] = 1 -for i in range(len(lst[0])): -    for j in range(sumx * 2 + 1): -        if dpx[i][j] != 0: -            dpx[i + 1][j + lst[0][i]] += 1 -            dpx[i + 1][j - lst[0][i]] += 1 -for i in range(len(lst[1])): -    for j in range(sumy * 2 + 1): -        if dpy[i][j] != 0: -            dpy[i + 1][j + lst[1][i]] += 1 -            dpy[i + 1][j - lst[1][i]] += 1 -# print(dpx) -# print(dpy) -if dpx[len(lst[0])][sumx + x] != 0 and dpy[len(lst[1])][sumy + y] != 0: +    quit() +yokolst = [[0] * (sum(yoko) * 2 + 1) for i in range(len(yoko) + 1)] +tatelst = [[0] * (sum(tate) * 2 + 1) for i in range(len(tate) + 1)] +yokolst[0][sum(yoko)] = 1 +tatelst[0][sum(tate)] = 1 +# print(yokolst) +# print(tatelst) +for i in range(len(tate)): +    for j in range(len(tatelst[0])): +        if tatelst[i][j] == 1: +            tatelst[i + 1][j + tate[i]] = 1 +            tatelst[i + 1][j - tate[i]] = 1 +for i in range(len(yoko)): +    for j in range(len(yokolst[0])): +        if yokolst[i][j] == 1: +            yokolst[i + 1][j + yoko[i]] = 1 +            yokolst[i + 1][j - yoko[i]] = 1 +# print(yokolst) +# print(tatelst) +if tatelst[-1][sum(tate) + y] == 1 and yokolst[-1][sum(yoko) + x] == 1: