S = eval(input())

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



if 'T' not in S:

    print(('Yes' if x==len(S) and y==0 else 'No'))

    exit()



sp = S.split('T')

x -= len(sp[0])



v_moves = []

h_moves = []

for i,s in enumerate(sp[1:]):

    if not s: continue

    if i%2==0:

        v_moves.append(len(s))

    else:

        h_moves.append(len(s))



if not h_moves:

    if x != 0:

        print('No')

        exit()

else:

    hs = set([0])

    for h in h_moves:

        tmp = set()

        for h2 in hs:

            tmp.add(h2 + h)

            tmp.add(h2 - h)

        hs = tmp

    if x not in hs:

        print('No')

        exit()



if not v_moves:

    if y != 0:

        print('No')

        exit()

else:

    vs = set([0])

    for v in v_moves:

        tmp = set()

        for v2 in vs:

            tmp.add(v2 + v)

            tmp.add(v2 - v)

        vs = tmp

    if y not in vs:

        print('No')

        exit()



print('Yes')

S = eval(input())

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

st = S.split('T')



X -= len(st[0])



xds = []

yds = []

for i,s in enumerate(st[1:]):

    if i%2:

        xds.append(len(s))

    else:

        yds.append(len(s))



def ok(to, ds):

    dp = set([0])

    for d in ds:

        tmp = []

        for v in dp:

            tmp.append(v+d)

            tmp.append(v-d)

        dp = set(tmp)

    return to in dp



print(('Yes' if ok(X,xds) and ok(Y,yds) else 'No'))
S = eval(input())
x, y = list(map(int, input().split()))
if "T" not in S:
    print(("Yes" if x == len(S) and y == 0 else "No"))
    exit()
sp = S.split("T")
x -= len(sp[0])
v_moves = []
h_moves = []
for i, s in enumerate(sp[1:]):
    if not s:
        continue
    if i % 2 == 0:
        v_moves.append(len(s))
    else:
        h_moves.append(len(s))
if not h_moves:
    if x != 0:
        print("No")
        exit()
else:
    hs = set([0])
    for h in h_moves:
        tmp = set()
        for h2 in hs:
            tmp.add(h2 + h)
            tmp.add(h2 - h)
        hs = tmp
    if x not in hs:
        print("No")
        exit()
if not v_moves:
    if y != 0:
        print("No")
        exit()
else:
    vs = set([0])
    for v in v_moves:
        tmp = set()
        for v2 in vs:
            tmp.add(v2 + v)
            tmp.add(v2 - v)
        vs = tmp
    if y not in vs:
        print("No")
        exit()
print("Yes")

S = eval(input())
X, Y = list(map(int, input().split()))
st = S.split("T")
X -= len(st[0])
xds = []
yds = []
for i, s in enumerate(st[1:]):
    if i % 2:
        xds.append(len(s))
    else:
        yds.append(len(s))


def ok(to, ds):
    dp = set([0])
    for d in ds:
        tmp = []
        for v in dp:
            tmp.append(v + d)
            tmp.append(v - d)
        dp = set(tmp)
    return to in dp


print(("Yes" if ok(X, xds) and ok(Y, yds) else "No"))

-x, y = list(map(int, input().split())) -if "T" not in S: -    print(("Yes" if x == len(S) and y == 0 else "No")) -    exit() -sp = S.split("T") -x -= len(sp[0]) -v_moves = [] -h_moves = [] -for i, s in enumerate(sp[1:]): -    if not s: -        continue -    if i % 2 == 0: -        v_moves.append(len(s)) +X, Y = list(map(int, input().split())) +st = S.split("T") +X -= len(st[0]) +xds = [] +yds = [] +for i, s in enumerate(st[1:]): +    if i % 2: +        xds.append(len(s)) -        h_moves.append(len(s)) -if not h_moves: -    if x != 0: -        print("No") -        exit() -else: -    hs = set([0]) -    for h in h_moves: -        tmp = set() -        for h2 in hs: -            tmp.add(h2 + h) -            tmp.add(h2 - h) -        hs = tmp -    if x not in hs: -        print("No") -        exit() -if not v_moves: -    if y != 0: -        print("No") -        exit() -else: -    vs = set([0]) -    for v in v_moves: -        tmp = set() -        for v2 in vs: -            tmp.add(v2 + v) -            tmp.add(v2 - v) -        vs = tmp -    if y not in vs: -        print("No") -        exit() -print("Yes") +        yds.append(len(s)) + + +def ok(to, ds): +    dp = set([0]) +    for d in ds: +        tmp = [] +        for v in dp: +            tmp.append(v + d) +            tmp.append(v - d) +        dp = set(tmp) +    return to in dp + + +print(("Yes" if ok(X, xds) and ok(Y, yds) else "No"))