from collections import defaultdict



s = eval(input())

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



d = [len(x) for x in s.split('T')]



dx = d[0::2]

n_dx = len(dx)

dp = {0}

for i in range(n_dx):

    tmp = set()

    for j in dp:

        if i == 0:

            tmp.add(j + dx[i])

        else:

            tmp.add(j - dx[i])

            tmp.add(j + dx[i])

    dp = tmp

x_flag = x in dp



dy = d[1::2]

n_dy = len(dy)

dp = {0}

for i in range(n_dy):

    tmp = set()

    for j in dp:

        tmp.add(j - dy[i])

        tmp.add(j + dy[i])

    dp = tmp

y_flag = y in dp



if x_flag and y_flag:

    print('Yes')

else:

    print('No')
from collections import defaultdict



s = eval(input())

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



d = [len(x) for x in s.split('T')]



dx = d[2::2]

n_dx = len(dx)

dp = {d[0]}

for i in range(n_dx):

    tmp = set()

    for j in dp:

        tmp.add(j - dx[i])

        tmp.add(j + dx[i])

    dp = tmp

x_flag = x in dp



dy = d[1::2]

n_dy = len(dy)

dp = {0}

for i in range(n_dy):

    tmp = set()

    for j in dp:

        tmp.add(j - dy[i])

        tmp.add(j + dy[i])

    dp = tmp

y_flag = y in dp



if x_flag and y_flag:

    print('Yes')

else:

    print('No')

from collections import defaultdict

s = eval(input())
x, y = list(map(int, input().split()))
d = [len(x) for x in s.split("T")]
dx = d[0::2]
n_dx = len(dx)
dp = {0}
for i in range(n_dx):
    tmp = set()
    for j in dp:
        if i == 0:
            tmp.add(j + dx[i])
        else:
            tmp.add(j - dx[i])
            tmp.add(j + dx[i])
    dp = tmp
x_flag = x in dp
dy = d[1::2]
n_dy = len(dy)
dp = {0}
for i in range(n_dy):
    tmp = set()
    for j in dp:
        tmp.add(j - dy[i])
        tmp.add(j + dy[i])
    dp = tmp
y_flag = y in dp
if x_flag and y_flag:
    print("Yes")
else:
    print("No")

from collections import defaultdict

s = eval(input())
x, y = list(map(int, input().split()))
d = [len(x) for x in s.split("T")]
dx = d[2::2]
n_dx = len(dx)
dp = {d[0]}
for i in range(n_dx):
    tmp = set()
    for j in dp:
        tmp.add(j - dx[i])
        tmp.add(j + dx[i])
    dp = tmp
x_flag = x in dp
dy = d[1::2]
n_dy = len(dy)
dp = {0}
for i in range(n_dy):
    tmp = set()
    for j in dp:
        tmp.add(j - dy[i])
        tmp.add(j + dy[i])
    dp = tmp
y_flag = y in dp
if x_flag and y_flag:
    print("Yes")
else:
    print("No")

-dx = d[0::2] +dx = d[2::2] -dp = {0} +dp = {d[0]} -        if i == 0: -            tmp.add(j + dx[i]) -        else: -            tmp.add(j - dx[i]) -            tmp.add(j + dx[i]) +        tmp.add(j - dx[i]) +        tmp.add(j + dx[i])