import sys

from collections import deque



s = deque(eval(input()) + 'T')

X, Y = list(map(int, input().split()))



while True:

    if s[0] == 'T':

        break

    s.popleft()

    X -= 1



dirx = True

x_list = []

y_list = []

count = 0

for c in s:

    if c == 'F':

        count += 1

    else:

        if count > 0:

            x_list.append(count) if dirx else y_list.append(count)

            count = 0

        dirx = not(dirx)



if (sum(x_list) + X) % 2 != 0 or (sum(y_list) + Y) % 2 != 0 or sum(x_list) < abs(X) or sum(y_list) < abs(Y):

    print('No')

    sys.exit()



dx = (sum(x_list) + abs(X)) // 2

dy = (sum(y_list) + abs(Y)) // 2



dp_x = [False for _ in range(dx + 1)]

dp_x[0] = True

for x in x_list:

    for i in range(dx - x, -1, -1):

        if dp_x[i] and i + x <= dx:

            dp_x[i + x] = True

if not dp_x[dx]:

    print('No')

    sys.exit()



dp_y = [False for _ in range(dy + 1)]

dp_y[0] = True

for y in y_list:

    for i in range(dy - y, -1, -1):

        if dp_y[i] and i + y <= dy:

            dp_y[i + y] = True

if not dp_y[dy]:

    print('No')

    sys.exit()



print('Yes')

import sys

from collections import deque



s = deque(eval(input()) + 'T')

X, Y = list(map(int, input().split()))



while True:

    if s[0] == 'T':

        break

    s.popleft()

    X -= 1



dirx = True

x_list = []

y_list = []

count = 0

for c in s:

    if c == 'F':

        count += 1

    else:

        if count > 0:

            x_list.append(count) if dirx else y_list.append(count)

            count = 0

        dirx = not(dirx)



if (sum(x_list) + X) % 2 != 0 or (sum(y_list) + Y) % 2 != 0 or sum(x_list) < abs(X) or sum(y_list) < abs(Y):

    print('No')

    sys.exit()



dx = (sum(x_list) - abs(X)) // 2

dp_x = [False for _ in range(dx + 1)]

dp_x[0] = True

for x in x_list:

    for i in range(dx - x, -1, -1):

        if dp_x[i]:

            dp_x[i + x] = True

    if dp_x[dx]:

        break

if not dp_x[dx]:

    print('No')

    sys.exit()



dy = (sum(y_list) - abs(Y)) // 2

dp_y = [False for _ in range(dy + 1)]

dp_y[0] = True

for y in y_list:

    for i in range(dy - y, -1, -1):

        if dp_y[i]:

            dp_y[i + y] = True

    if dp_y[dy]:

        break

if not dp_y[dy]:

    print('No')

    sys.exit()



print('Yes')

import sys
from collections import deque

s = deque(eval(input()) + "T")
X, Y = list(map(int, input().split()))
while True:
    if s[0] == "T":
        break
    s.popleft()
    X -= 1
dirx = True
x_list = []
y_list = []
count = 0
for c in s:
    if c == "F":
        count += 1
    else:
        if count > 0:
            x_list.append(count) if dirx else y_list.append(count)
            count = 0
        dirx = not (dirx)
if (
    (sum(x_list) + X) % 2 != 0
    or (sum(y_list) + Y) % 2 != 0
    or sum(x_list) < abs(X)
    or sum(y_list) < abs(Y)
):
    print("No")
    sys.exit()
dx = (sum(x_list) + abs(X)) // 2
dy = (sum(y_list) + abs(Y)) // 2
dp_x = [False for _ in range(dx + 1)]
dp_x[0] = True
for x in x_list:
    for i in range(dx - x, -1, -1):
        if dp_x[i] and i + x <= dx:
            dp_x[i + x] = True
if not dp_x[dx]:
    print("No")
    sys.exit()
dp_y = [False for _ in range(dy + 1)]
dp_y[0] = True
for y in y_list:
    for i in range(dy - y, -1, -1):
        if dp_y[i] and i + y <= dy:
            dp_y[i + y] = True
if not dp_y[dy]:
    print("No")
    sys.exit()
print("Yes")

import sys
from collections import deque

s = deque(eval(input()) + "T")
X, Y = list(map(int, input().split()))
while True:
    if s[0] == "T":
        break
    s.popleft()
    X -= 1
dirx = True
x_list = []
y_list = []
count = 0
for c in s:
    if c == "F":
        count += 1
    else:
        if count > 0:
            x_list.append(count) if dirx else y_list.append(count)
            count = 0
        dirx = not (dirx)
if (
    (sum(x_list) + X) % 2 != 0
    or (sum(y_list) + Y) % 2 != 0
    or sum(x_list) < abs(X)
    or sum(y_list) < abs(Y)
):
    print("No")
    sys.exit()
dx = (sum(x_list) - abs(X)) // 2
dp_x = [False for _ in range(dx + 1)]
dp_x[0] = True
for x in x_list:
    for i in range(dx - x, -1, -1):
        if dp_x[i]:
            dp_x[i + x] = True
    if dp_x[dx]:
        break
if not dp_x[dx]:
    print("No")
    sys.exit()
dy = (sum(y_list) - abs(Y)) // 2
dp_y = [False for _ in range(dy + 1)]
dp_y[0] = True
for y in y_list:
    for i in range(dy - y, -1, -1):
        if dp_y[i]:
            dp_y[i + y] = True
    if dp_y[dy]:
        break
if not dp_y[dy]:
    print("No")
    sys.exit()
print("Yes")

-dx = (sum(x_list) + abs(X)) // 2 -dy = (sum(y_list) + abs(Y)) // 2 +dx = (sum(x_list) - abs(X)) // 2 -        if dp_x[i] and i + x <= dx: +        if dp_x[i]: +    if dp_x[dx]: +        break +dy = (sum(y_list) - abs(Y)) // 2 -        if dp_y[i] and i + y <= dy: +        if dp_y[i]: +    if dp_y[dy]: +        break