import sys,collections

sys.setrecursionlimit(10**7)

def Is(): return [int(x) for x in sys.stdin.readline().split()]

def S(): return eval(input())

 

s = S()

gx,gy = Is()

l = s.split("T")

for i in range(len(l)):

    l[i] = len(l[i])

xlis,ylis = l[::2],l[1::2]

sx = xlis.pop(0) if len(xlis)>0 else 0

sy = 0

xlis.sort(reverse=True)

ylis.sort(reverse=True)

def calc(start,goal,lis):

    p = start

    for e in lis:

        if p < goal:

            p += e

        else:

            p -= e

    return p == goal

if calc(sx,gx,xlis) and calc(sy,gy,ylis):

    print("Yes")

else:

    print("No")
s = input().split("T")

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

for i,e in enumerate(s):

    s[i] = len(e)

xs,ys = s[::2],s[1::2]

x = xs.pop(0) if len(xs)>0 else 0

y = 0

xs.sort(reverse=True)

ys.sort(reverse=True)

def c(p,g,lis):

    for e in lis:

        if p <= g:

            p += e

        else:

            p -= e

    return p == g

if c(x,gx,xs) and c(y,gy,ys):

    print("Yes")

else:

    print("No")
import sys, collections

sys.setrecursionlimit(10**7)


def Is():
    return [int(x) for x in sys.stdin.readline().split()]


def S():
    return eval(input())


s = S()
gx, gy = Is()
l = s.split("T")
for i in range(len(l)):
    l[i] = len(l[i])
xlis, ylis = l[::2], l[1::2]
sx = xlis.pop(0) if len(xlis) > 0 else 0
sy = 0
xlis.sort(reverse=True)
ylis.sort(reverse=True)


def calc(start, goal, lis):
    p = start
    for e in lis:
        if p < goal:
            p += e
        else:
            p -= e
    return p == goal


if calc(sx, gx, xlis) and calc(sy, gy, ylis):
    print("Yes")
else:
    print("No")

s = input().split("T")
gx, gy = list(map(int, input().split()))
for i, e in enumerate(s):
    s[i] = len(e)
xs, ys = s[::2], s[1::2]
x = xs.pop(0) if len(xs) > 0 else 0
y = 0
xs.sort(reverse=True)
ys.sort(reverse=True)


def c(p, g, lis):
    for e in lis:
        if p <= g:
            p += e
        else:
            p -= e
    return p == g


if c(x, gx, xs) and c(y, gy, ys):
    print("Yes")
else:
    print("No")

-import sys, collections - -sys.setrecursionlimit(10**7) +s = input().split("T") +gx, gy = list(map(int, input().split())) +for i, e in enumerate(s): +    s[i] = len(e) +xs, ys = s[::2], s[1::2] +x = xs.pop(0) if len(xs) > 0 else 0 +y = 0 +xs.sort(reverse=True) +ys.sort(reverse=True) -def Is(): -    return [int(x) for x in sys.stdin.readline().split()] - - -def S(): -    return eval(input()) - - -s = S() -gx, gy = Is() -l = s.split("T") -for i in range(len(l)): -    l[i] = len(l[i]) -xlis, ylis = l[::2], l[1::2] -sx = xlis.pop(0) if len(xlis) > 0 else 0 -sy = 0 -xlis.sort(reverse=True) -ylis.sort(reverse=True) - - -def calc(start, goal, lis): -    p = start +def c(p, g, lis): -        if p < goal: +        if p <= g: -    return p == goal +    return p == g -if calc(sx, gx, xlis) and calc(sy, gy, ylis): +if c(x, gx, xs) and c(y, gy, ys):