import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    S = eval(input())

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



    S = list(map(len, S.split("T")))

    init_x = S[0]

    is_x = 0

    to_x, to_y = [], []

    for i in range(1, len(S)):

        if S[i]:

            to_x.append(S[i]) if is_x else to_y.append(S[i])

        is_x ^= 1



    now_x = {init_x}

    for x in to_x:

        tmp = set()

        for now in now_x:

            tmp.add(now - x)

            tmp.add(now + x)

        now_x = tmp



    now_y = {0}

    for y in to_y:

        tmp = set()

        for now in now_y:

            tmp.add(now - y)

            tmp.add(now + y)

        now_y = tmp



    print(("Yes" if X in now_x and Y in now_y else "No"))





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    S = list(input().split("T"))

    gx, gy = list(map(int, input().split()))



    to_X = 0

    init_x = len(S[0])

    S.pop(0)

    X, Y = [], []

    for s in S:

        X.append(len(s)) if to_X else Y.append(len(s))

        to_X ^= 1



    now_x = {init_x}

    for x in X:

        tmp = set()

        for prev_x in now_x:

            tmp.add(prev_x + x)

            tmp.add(prev_x - x)

        now_x = tmp



    now_y = {0}

    for y in Y:

        tmp = set()

        for prev_y in now_y:

            tmp.add(prev_y + y)

            tmp.add(prev_y - y)

        now_y = tmp



    print(("Yes" if gx in now_x and gy in now_y else "No"))





if __name__ == '__main__':

    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    S = eval(input())
    X, Y = list(map(int, input().split()))
    S = list(map(len, S.split("T")))
    init_x = S[0]
    is_x = 0
    to_x, to_y = [], []
    for i in range(1, len(S)):
        if S[i]:
            to_x.append(S[i]) if is_x else to_y.append(S[i])
        is_x ^= 1
    now_x = {init_x}
    for x in to_x:
        tmp = set()
        for now in now_x:
            tmp.add(now - x)
            tmp.add(now + x)
        now_x = tmp
    now_y = {0}
    for y in to_y:
        tmp = set()
        for now in now_y:
            tmp.add(now - y)
            tmp.add(now + y)
        now_y = tmp
    print(("Yes" if X in now_x and Y in now_y else "No"))


if __name__ == "__main__":
    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    S = list(input().split("T"))
    gx, gy = list(map(int, input().split()))
    to_X = 0
    init_x = len(S[0])
    S.pop(0)
    X, Y = [], []
    for s in S:
        X.append(len(s)) if to_X else Y.append(len(s))
        to_X ^= 1
    now_x = {init_x}
    for x in X:
        tmp = set()
        for prev_x in now_x:
            tmp.add(prev_x + x)
            tmp.add(prev_x - x)
        now_x = tmp
    now_y = {0}
    for y in Y:
        tmp = set()
        for prev_y in now_y:
            tmp.add(prev_y + y)
            tmp.add(prev_y - y)
        now_y = tmp
    print(("Yes" if gx in now_x and gy in now_y else "No"))


if __name__ == "__main__":
    resolve()

-    S = eval(input()) -    X, Y = list(map(int, input().split())) -    S = list(map(len, S.split("T"))) -    init_x = S[0] -    is_x = 0 -    to_x, to_y = [], [] -    for i in range(1, len(S)): -        if S[i]: -            to_x.append(S[i]) if is_x else to_y.append(S[i]) -        is_x ^= 1 +    S = list(input().split("T")) +    gx, gy = list(map(int, input().split())) +    to_X = 0 +    init_x = len(S[0]) +    S.pop(0) +    X, Y = [], [] +    for s in S: +        X.append(len(s)) if to_X else Y.append(len(s)) +        to_X ^= 1 -    for x in to_x: +    for x in X: -        for now in now_x: -            tmp.add(now - x) -            tmp.add(now + x) +        for prev_x in now_x: +            tmp.add(prev_x + x) +            tmp.add(prev_x - x) -    for y in to_y: +    for y in Y: -        for now in now_y: -            tmp.add(now - y) -            tmp.add(now + y) +        for prev_y in now_y: +            tmp.add(prev_y + y) +            tmp.add(prev_y - y) -    print(("Yes" if X in now_x and Y in now_y else "No")) +    print(("Yes" if gx in now_x and gy in now_y else "No"))