from copy import copy

s = eval(input()) + "T"

n=len(s)

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



xy=[[],[]]



sgn = 1

now = n

for i in range(n):

    if s[i] == "T":

        x -= i

        now = i + 1

        break

for i in range(now, n):

    if s[i] == "T":

        xy[sgn].append(i - now)

        now = i + 1

        sgn ^= 1





cur = {0}

for i in xy[0]:

    nxt = set()

    for j in cur:

        nxt.add(j + i)

        nxt.add(j - i)

    cur = copy(nxt)



flag = x in cur



cur = {0}

for i in xy[1]:

    nxt = set()

    for j in cur:

        nxt.add(j + i)

        nxt.add(j - i)

    cur = copy(nxt)



print(("Yes" if flag and y in cur else "No"))
from copy import copy

s = eval(input())

n=len(s)

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



d = [len(v) for v in s.split("T")]

x -= d[0]

a = d[2::2]

b = d[1::2]





def c(d, x):

    cur = {0}

    for i in d:

        nxt = set()

        for j in cur:

            nxt.add(j + i)

            nxt.add(j - i)

        cur = copy(nxt)

    return x in cur



print(("Yes" if c(a, x) and c(b, y) else "No"))
from copy import copy

s = eval(input()) + "T"
n = len(s)
x, y = list(map(int, input().split()))
xy = [[], []]
sgn = 1
now = n
for i in range(n):
    if s[i] == "T":
        x -= i
        now = i + 1
        break
for i in range(now, n):
    if s[i] == "T":
        xy[sgn].append(i - now)
        now = i + 1
        sgn ^= 1
cur = {0}
for i in xy[0]:
    nxt = set()
    for j in cur:
        nxt.add(j + i)
        nxt.add(j - i)
    cur = copy(nxt)
flag = x in cur
cur = {0}
for i in xy[1]:
    nxt = set()
    for j in cur:
        nxt.add(j + i)
        nxt.add(j - i)
    cur = copy(nxt)
print(("Yes" if flag and y in cur else "No"))

from copy import copy

s = eval(input())
n = len(s)
x, y = list(map(int, input().split()))
d = [len(v) for v in s.split("T")]
x -= d[0]
a = d[2::2]
b = d[1::2]


def c(d, x):
    cur = {0}
    for i in d:
        nxt = set()
        for j in cur:
            nxt.add(j + i)
            nxt.add(j - i)
        cur = copy(nxt)
    return x in cur


print(("Yes" if c(a, x) and c(b, y) else "No"))

-s = eval(input()) + "T" +s = eval(input()) -xy = [[], []] -sgn = 1 -now = n -for i in range(n): -    if s[i] == "T": -        x -= i -        now = i + 1 -        break -for i in range(now, n): -    if s[i] == "T": -        xy[sgn].append(i - now) -        now = i + 1 -        sgn ^= 1 -cur = {0} -for i in xy[0]: -    nxt = set() -    for j in cur: -        nxt.add(j + i) -        nxt.add(j - i) -    cur = copy(nxt) -flag = x in cur -cur = {0} -for i in xy[1]: -    nxt = set() -    for j in cur: -        nxt.add(j + i) -        nxt.add(j - i) -    cur = copy(nxt) -print(("Yes" if flag and y in cur else "No")) +d = [len(v) for v in s.split("T")] +x -= d[0] +a = d[2::2] +b = d[1::2] + + +def c(d, x): +    cur = {0} +    for i in d: +        nxt = set() +        for j in cur: +            nxt.add(j + i) +            nxt.add(j - i) +        cur = copy(nxt) +    return x in cur + + +print(("Yes" if c(a, x) and c(b, y) else "No"))