s = eval(input())

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



fs = s.split('T')

f_num = [len(f) for f in fs]

dir_lst = [[], []]

for i in range(len(f_num)):

    dir_lst[i % 2].append(f_num[i])

x_lst = dir_lst[0]

x -= x_lst[0]

x_lst = x_lst[1:]

y_lst = dir_lst[1]



can_x = False

can_y = False



s = set([0])

for x_ in x_lst:

    s_ = set()

    for e in s:

        s_.add(e+x_)

        s_.add(e-x_)

    s = s_

if x in s:

    can_x = True



s = set([0])

for y_ in y_lst:

    s_ = set()

    for e in s:

        s_.add(e+y_)

        s_.add(e-y_)

    s = s_

if y in s:

    can_y = True



if can_x and can_y:

    print('Yes')

else:

    print('No')

s = eval(input())

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





def part_sum0(a, A):

    # 初期化

    N = len(a)

    dp = [[0 for i in range(A + 1)] for j in range(N + 1)]

    dp[0][0] = 1



    # DP

    for i in range(N):

        for j in range(A + 1):

            if a[i] <= j:

                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]

            else:

                dp[i + 1][j] = dp[i][j]

    return dp[N][A]





fs = s.split('T')

f_num = [len(f) for f in fs]

dir_lst = [[], []]

for i in range(len(f_num)):

    dir_lst[i % 2].append(f_num[i])

x_lst = dir_lst[0]

x -= x_lst[0]

x_lst = x_lst[1:]

y_lst = dir_lst[1]



can_x = False

can_y = False



dx = abs(sum(x_lst)) - abs(x)

if (dx % 2 == 1) or (dx < 0):

    pass

elif dx == 0:

    can_x = True

else:

    if part_sum0(x_lst, dx // 2):

        can_x = True



if can_x:

    dy = abs(sum(y_lst)) - abs(y)

    if (dy % 2 == 1) or (dy < 0):

        pass

    elif dy == 0:

        can_y = True

    else:

        if part_sum0(y_lst, dy // 2):

            can_y = True



if can_y:

    print('Yes')

else:

    print('No')

s = eval(input())
x, y = list(map(int, input().split()))
fs = s.split("T")
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
x -= x_lst[0]
x_lst = x_lst[1:]
y_lst = dir_lst[1]
can_x = False
can_y = False
s = set([0])
for x_ in x_lst:
    s_ = set()
    for e in s:
        s_.add(e + x_)
        s_.add(e - x_)
    s = s_
if x in s:
    can_x = True
s = set([0])
for y_ in y_lst:
    s_ = set()
    for e in s:
        s_.add(e + y_)
        s_.add(e - y_)
    s = s_
if y in s:
    can_y = True
if can_x and can_y:
    print("Yes")
else:
    print("No")

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


def part_sum0(a, A):
    # 初期化
    N = len(a)
    dp = [[0 for i in range(A + 1)] for j in range(N + 1)]
    dp[0][0] = 1
    # DP
    for i in range(N):
        for j in range(A + 1):
            if a[i] <= j:
                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j]
            else:
                dp[i + 1][j] = dp[i][j]
    return dp[N][A]


fs = s.split("T")
f_num = [len(f) for f in fs]
dir_lst = [[], []]
for i in range(len(f_num)):
    dir_lst[i % 2].append(f_num[i])
x_lst = dir_lst[0]
x -= x_lst[0]
x_lst = x_lst[1:]
y_lst = dir_lst[1]
can_x = False
can_y = False
dx = abs(sum(x_lst)) - abs(x)
if (dx % 2 == 1) or (dx < 0):
    pass
elif dx == 0:
    can_x = True
else:
    if part_sum0(x_lst, dx // 2):
        can_x = True
if can_x:
    dy = abs(sum(y_lst)) - abs(y)
    if (dy % 2 == 1) or (dy < 0):
        pass
    elif dy == 0:
        can_y = True
    else:
        if part_sum0(y_lst, dy // 2):
            can_y = True
if can_y:
    print("Yes")
else:
    print("No")

+ + +def part_sum0(a, A): +    # 初期化 +    N = len(a) +    dp = [[0 for i in range(A + 1)] for j in range(N + 1)] +    dp[0][0] = 1 +    # DP +    for i in range(N): +        for j in range(A + 1): +            if a[i] <= j: +                dp[i + 1][j] = dp[i][j - a[i]] or dp[i][j] +            else: +                dp[i + 1][j] = dp[i][j] +    return dp[N][A] + + -s = set([0]) -for x_ in x_lst: -    s_ = set() -    for e in s: -        s_.add(e + x_) -        s_.add(e - x_) -    s = s_ -if x in s: +dx = abs(sum(x_lst)) - abs(x) +if (dx % 2 == 1) or (dx < 0): +    pass +elif dx == 0: -s = set([0]) -for y_ in y_lst: -    s_ = set() -    for e in s: -        s_.add(e + y_) -        s_.add(e - y_) -    s = s_ -if y in s: -    can_y = True -if can_x and can_y: +else: +    if part_sum0(x_lst, dx // 2): +        can_x = True +if can_x: +    dy = abs(sum(y_lst)) - abs(y) +    if (dy % 2 == 1) or (dy < 0): +        pass +    elif dy == 0: +        can_y = True +    else: +        if part_sum0(y_lst, dy // 2): +            can_y = True +if can_y: