s = eval(input())

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



s = s.split("T")

s_x = []

s_y = []

for i in range(0,len(s),2):

    s_x.append(s[i])

for i in range(1,len(s),2):

    s_y.append(s[i])

x_cou = []

y_cou = []

for i in range(len(s_x)):

    x_cou.append(s_x[i].count("F"))

for j in range(len(s_y)):

    y_cou.append(s_y[j].count("F"))



if sum(x_cou) < abs(x) or sum(y_cou) <abs(y):

    print("No")

    exit()



x = x - x_cou[0]

x_list = set([0])

for i in range(len(x_cou)-1,0,-1):

    new_xlist = set()

    for j in range(len(x_list)):

        k = x_list.pop()

        new_xlist.add(k + x_cou[i])

        new_xlist.add(k - x_cou[i])

    x_list = new_xlist



y_list = set([0])

for i in range(len(y_cou)-1,-1,-1):

    new_ylist = set([])

    for j in range(len(y_list)):

        l = y_list.pop()

        new_ylist.add(l + y_cou[i])

        new_ylist.add(l - y_cou[i])

    y_list = new_ylist



if x in x_list and y in y_list:

    print("Yes")

else:

    print("No")

s = [len(w) for w in input().split("T")]

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



lisx = s[2::2]

lisy = s[1::2]



nowx = {s[0]}

nowy = {0}



for x1 in lisx:

  gone = set()

  for x2 in nowx:

    gone.add(x2 + x1)

    gone.add(x2 - x1)

  nowx = gone



for y1 in lisy:

  gone = set()

  for y2 in nowy:

    gone.add(y2 + y1)

    gone.add(y2 - y1)

  nowy = gone





if x in nowx and y in nowy:print("Yes")

else:print("No")
s = eval(input())
x, y = list(map(int, input().split()))
s = s.split("T")
s_x = []
s_y = []
for i in range(0, len(s), 2):
    s_x.append(s[i])
for i in range(1, len(s), 2):
    s_y.append(s[i])
x_cou = []
y_cou = []
for i in range(len(s_x)):
    x_cou.append(s_x[i].count("F"))
for j in range(len(s_y)):
    y_cou.append(s_y[j].count("F"))
if sum(x_cou) < abs(x) or sum(y_cou) < abs(y):
    print("No")
    exit()
x = x - x_cou[0]
x_list = set([0])
for i in range(len(x_cou) - 1, 0, -1):
    new_xlist = set()
    for j in range(len(x_list)):
        k = x_list.pop()
        new_xlist.add(k + x_cou[i])
        new_xlist.add(k - x_cou[i])
    x_list = new_xlist
y_list = set([0])
for i in range(len(y_cou) - 1, -1, -1):
    new_ylist = set([])
    for j in range(len(y_list)):
        l = y_list.pop()
        new_ylist.add(l + y_cou[i])
        new_ylist.add(l - y_cou[i])
    y_list = new_ylist
if x in x_list and y in y_list:
    print("Yes")
else:
    print("No")

s = [len(w) for w in input().split("T")]
x, y = list(map(int, input().split()))
lisx = s[2::2]
lisy = s[1::2]
nowx = {s[0]}
nowy = {0}
for x1 in lisx:
    gone = set()
    for x2 in nowx:
        gone.add(x2 + x1)
        gone.add(x2 - x1)
    nowx = gone
for y1 in lisy:
    gone = set()
    for y2 in nowy:
        gone.add(y2 + y1)
        gone.add(y2 - y1)
    nowy = gone
if x in nowx and y in nowy:
    print("Yes")
else:
    print("No")

-s = eval(input()) +s = [len(w) for w in input().split("T")] -s = s.split("T") -s_x = [] -s_y = [] -for i in range(0, len(s), 2): -    s_x.append(s[i]) -for i in range(1, len(s), 2): -    s_y.append(s[i]) -x_cou = [] -y_cou = [] -for i in range(len(s_x)): -    x_cou.append(s_x[i].count("F")) -for j in range(len(s_y)): -    y_cou.append(s_y[j].count("F")) -if sum(x_cou) < abs(x) or sum(y_cou) < abs(y): -    print("No") -    exit() -x = x - x_cou[0] -x_list = set([0]) -for i in range(len(x_cou) - 1, 0, -1): -    new_xlist = set() -    for j in range(len(x_list)): -        k = x_list.pop() -        new_xlist.add(k + x_cou[i]) -        new_xlist.add(k - x_cou[i]) -    x_list = new_xlist -y_list = set([0]) -for i in range(len(y_cou) - 1, -1, -1): -    new_ylist = set([]) -    for j in range(len(y_list)): -        l = y_list.pop() -        new_ylist.add(l + y_cou[i]) -        new_ylist.add(l - y_cou[i]) -    y_list = new_ylist -if x in x_list and y in y_list: +lisx = s[2::2] +lisy = s[1::2] +nowx = {s[0]} +nowy = {0} +for x1 in lisx: +    gone = set() +    for x2 in nowx: +        gone.add(x2 + x1) +        gone.add(x2 - x1) +    nowx = gone +for y1 in lisy: +    gone = set() +    for y2 in nowy: +        gone.add(y2 + y1) +        gone.add(y2 - y1) +    nowy = gone +if x in nowx and y in nowy: