# https://atcoder.jp/contests/abc082/submissions/13655878

# D - FT Robot

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    s = eval(input())

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



    spl = list(map(len, s.split("T")))

    init_x = spl[0]

    is_x = 0

    to_x, to_y = [], []

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

        if spl[i]:

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

        is_x ^= 1



    now_x = [init_x]

    for move in to_x:

        nx = set()

        for x in now_x:

            nx.add(x + move)

            nx.add(x - move)

        now_x = nx



    now_y = [0]

    for move in to_y:

        ny = set()

        for y in now_y:

            ny.add(y + move)

            ny.add(y - move)

        now_y = ny



    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()

# https://atcoder.jp/contests/abc082/submissions/13655878
# D - FT Robot
import sys

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


def resolve():
    s = eval(input())
    gx, gy = list(map(int, input().split()))
    spl = list(map(len, s.split("T")))
    init_x = spl[0]
    is_x = 0
    to_x, to_y = [], []
    for i in range(1, len(spl)):
        if spl[i]:
            to_x.append(spl[i]) if is_x else to_y.append(spl[i])
        is_x ^= 1
    now_x = [init_x]
    for move in to_x:
        nx = set()
        for x in now_x:
            nx.add(x + move)
            nx.add(x - move)
        now_x = nx
    now_y = [0]
    for move in to_y:
        ny = set()
        for y in now_y:
            ny.add(y + move)
            ny.add(y - move)
        now_y = ny
    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()

-# https://atcoder.jp/contests/abc082/submissions/13655878 -# D - FT Robot -    s = eval(input()) -    gx, gy = list(map(int, input().split())) -    spl = list(map(len, s.split("T"))) -    init_x = spl[0] +    S = eval(input()) +    X, Y = list(map(int, input().split())) +    S = list(map(len, S.split("T"))) +    init_x = S[0] -    for i in range(1, len(spl)): -        if spl[i]: -            to_x.append(spl[i]) if is_x else to_y.append(spl[i]) +    for i in range(1, len(S)): +        if S[i]: +            to_x.append(S[i]) if is_x else to_y.append(S[i]) -    now_x = [init_x] -    for move in to_x: -        nx = set() -        for x in now_x: -            nx.add(x + move) -            nx.add(x - move) -        now_x = nx -    now_y = [0] -    for move in to_y: -        ny = set() -        for y in now_y: -            ny.add(y + move) -            ny.add(y - move) -        now_y = ny -    print(("Yes" if gx in now_x and gy in now_y else "No")) +    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"))