S = str(eval(input()))

N = len(S)

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

X = []; Y =[]

Flag = True #Trueならx軸、Falseならy軸

seq = 0

for i in range(N):

  if S[i] == "T":

    if Flag:

      X.append(seq)

    if not Flag:

      Y.append(seq)

    Flag = not Flag

    seq = 0

  else:

    seq += 1

    if i == N-1:

      if Flag:

        X.append(seq)

      if not Flag:

        Y.append(seq)

#print(X,Y)

num = 8100 #真ん中

MAX = num*2+1

#X方向i回目でjにいる

dpx = [0 for _ in range(MAX)]

dpx[num] = 1

dpy = [0 for _ in range(MAX)]

dpy[num] = 1

for i in range(len(X)):

  px = [0 for _ in range(MAX)]

  px,dpx = dpx,px

  step = X[i]

  for j in range(MAX):

    if j -step >= 0:

      dpx[j] = max(dpx[j],px[j-step])

    if j + step < MAX and i != 0: #一番最初は左に戻れない

      dpx[j] = max(dpx[j],px[j+step])

for i in range(len(Y)):

  py = [0 for _ in range(MAX)]

  py,dpy = dpy,py

  step = Y[i]

  for j in range(MAX):

    if j -step >= 0:

      dpy[j] = max(dpy[j],py[j-step])

    if j + step < MAX:

      dpy[j] = max(dpy[j],py[j+step])

x += num;y+= num

#print(dpx)

#print(dpy)

if dpx[x] == 1 and dpy[y] == 1:

  print("Yes")

else:

  print("No")

  

      

     

s = str(eval(input())); n = len(s)

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

Yoko = []; Tate = []

Flag = 0; cnt = 0

Max_x = 0; Max_y = 0

for i in range(n):

  if s[i] == "F":

    cnt += 1

    if i == n-1: #最後なら登録

      if Flag == 0:

        Max_x += cnt

        Yoko.append(cnt)

      else:

        Max_y += cnt

        Tate.append(cnt)      

  else: #T

    if Flag == 0:

      Max_x += cnt

      Yoko.append(cnt)

    else:

      Max_y += cnt

      Tate.append(cnt)

    cnt = 0

    Flag = Flag^1

#print(Yoko,Tate)

MAX_dpx = Max_x*2+1

dp = [0 for _ in range(MAX_dpx)]

dp[Max_x] = 1



for i,x in enumerate(Yoko):

  p = [0 for _ in range(MAX_dpx)]

  p,dp = dp,p

  for j in range(MAX_dpx):

    if i == 0: #i=0の時は右向きだけ

      if 0<=j+x<MAX_dpx:

        dp[j+x] = max(dp[j+x], p[j])

    else:

      if 0<=j+x<MAX_dpx:

        dp[j+x] = max(dp[j+x], p[j])

      if 0<=j-x<MAX_dpx:

        dp[j-x] = max(dp[j-x], p[j])

  #print(dp)

#print(dp)

#print(gx+Max_x,MAX_dpx)

if gx+Max_x >= MAX_dpx or gx+Max_x < 0 or dp[gx+Max_x] == 0:

  print("No");exit()



MAX_dpy = Max_y*2+1

dp = [0 for _ in range(MAX_dpy)]

dp[Max_y] = 1



for i,y in enumerate(Tate):

  p = [0 for _ in range(MAX_dpy)]

  p,dp = dp,p

  for j in range(MAX_dpy):

    if 0<=j+y<MAX_dpy:

      dp[j+y] = max(dp[j+y], p[j])

    if 0<=j-y<MAX_dpy:

      dp[j-y] = max(dp[j-y], p[j])

  #print(dp)

#print(dp)

if gy+Max_y >= MAX_dpy or gy+Max_y < 0 or dp[gy+Max_y] == 0:

  print("No")

else:

  print("Yes")
S = str(eval(input()))
N = len(S)
x, y = list(map(int, input().split()))
X = []
Y = []
Flag = True  # Trueならx軸、Falseならy軸
seq = 0
for i in range(N):
    if S[i] == "T":
        if Flag:
            X.append(seq)
        if not Flag:
            Y.append(seq)
        Flag = not Flag
        seq = 0
    else:
        seq += 1
        if i == N - 1:
            if Flag:
                X.append(seq)
            if not Flag:
                Y.append(seq)
# print(X,Y)
num = 8100  # 真ん中
MAX = num * 2 + 1
# X方向i回目でjにいる
dpx = [0 for _ in range(MAX)]
dpx[num] = 1
dpy = [0 for _ in range(MAX)]
dpy[num] = 1
for i in range(len(X)):
    px = [0 for _ in range(MAX)]
    px, dpx = dpx, px
    step = X[i]
    for j in range(MAX):
        if j - step >= 0:
            dpx[j] = max(dpx[j], px[j - step])
        if j + step < MAX and i != 0:  # 一番最初は左に戻れない
            dpx[j] = max(dpx[j], px[j + step])
for i in range(len(Y)):
    py = [0 for _ in range(MAX)]
    py, dpy = dpy, py
    step = Y[i]
    for j in range(MAX):
        if j - step >= 0:
            dpy[j] = max(dpy[j], py[j - step])
        if j + step < MAX:
            dpy[j] = max(dpy[j], py[j + step])
x += num
y += num
# print(dpx)
# print(dpy)
if dpx[x] == 1 and dpy[y] == 1:
    print("Yes")
else:
    print("No")

s = str(eval(input()))
n = len(s)
gx, gy = list(map(int, input().split()))
Yoko = []
Tate = []
Flag = 0
cnt = 0
Max_x = 0
Max_y = 0
for i in range(n):
    if s[i] == "F":
        cnt += 1
        if i == n - 1:  # 最後なら登録
            if Flag == 0:
                Max_x += cnt
                Yoko.append(cnt)
            else:
                Max_y += cnt
                Tate.append(cnt)
    else:  # T
        if Flag == 0:
            Max_x += cnt
            Yoko.append(cnt)
        else:
            Max_y += cnt
            Tate.append(cnt)
        cnt = 0
        Flag = Flag ^ 1
# print(Yoko,Tate)
MAX_dpx = Max_x * 2 + 1
dp = [0 for _ in range(MAX_dpx)]
dp[Max_x] = 1
for i, x in enumerate(Yoko):
    p = [0 for _ in range(MAX_dpx)]
    p, dp = dp, p
    for j in range(MAX_dpx):
        if i == 0:  # i=0の時は右向きだけ
            if 0 <= j + x < MAX_dpx:
                dp[j + x] = max(dp[j + x], p[j])
        else:
            if 0 <= j + x < MAX_dpx:
                dp[j + x] = max(dp[j + x], p[j])
            if 0 <= j - x < MAX_dpx:
                dp[j - x] = max(dp[j - x], p[j])
    # print(dp)
# print(dp)
# print(gx+Max_x,MAX_dpx)
if gx + Max_x >= MAX_dpx or gx + Max_x < 0 or dp[gx + Max_x] == 0:
    print("No")
    exit()
MAX_dpy = Max_y * 2 + 1
dp = [0 for _ in range(MAX_dpy)]
dp[Max_y] = 1
for i, y in enumerate(Tate):
    p = [0 for _ in range(MAX_dpy)]
    p, dp = dp, p
    for j in range(MAX_dpy):
        if 0 <= j + y < MAX_dpy:
            dp[j + y] = max(dp[j + y], p[j])
        if 0 <= j - y < MAX_dpy:
            dp[j - y] = max(dp[j - y], p[j])
    # print(dp)
# print(dp)
if gy + Max_y >= MAX_dpy or gy + Max_y < 0 or dp[gy + Max_y] == 0:
    print("No")
else:
    print("Yes")

-S = str(eval(input())) -N = len(S) -x, y = list(map(int, input().split())) -X = [] -Y = [] -Flag = True  # Trueならx軸、Falseならy軸 -seq = 0 -for i in range(N): -    if S[i] == "T": -        if Flag: -            X.append(seq) -        if not Flag: -            Y.append(seq) -        Flag = not Flag -        seq = 0 -    else: -        seq += 1 -        if i == N - 1: -            if Flag: -                X.append(seq) -            if not Flag: -                Y.append(seq) -# print(X,Y) -num = 8100  # 真ん中 -MAX = num * 2 + 1 -# X方向i回目でjにいる -dpx = [0 for _ in range(MAX)] -dpx[num] = 1 -dpy = [0 for _ in range(MAX)] -dpy[num] = 1 -for i in range(len(X)): -    px = [0 for _ in range(MAX)] -    px, dpx = dpx, px -    step = X[i] -    for j in range(MAX): -        if j - step >= 0: -            dpx[j] = max(dpx[j], px[j - step]) -        if j + step < MAX and i != 0:  # 一番最初は左に戻れない -            dpx[j] = max(dpx[j], px[j + step]) -for i in range(len(Y)): -    py = [0 for _ in range(MAX)] -    py, dpy = dpy, py -    step = Y[i] -    for j in range(MAX): -        if j - step >= 0: -            dpy[j] = max(dpy[j], py[j - step]) -        if j + step < MAX: -            dpy[j] = max(dpy[j], py[j + step]) -x += num -y += num -# print(dpx) -# print(dpy) -if dpx[x] == 1 and dpy[y] == 1: +s = str(eval(input())) +n = len(s) +gx, gy = list(map(int, input().split())) +Yoko = [] +Tate = [] +Flag = 0 +cnt = 0 +Max_x = 0 +Max_y = 0 +for i in range(n): +    if s[i] == "F": +        cnt += 1 +        if i == n - 1:  # 最後なら登録 +            if Flag == 0: +                Max_x += cnt +                Yoko.append(cnt) +            else: +                Max_y += cnt +                Tate.append(cnt) +    else:  # T +        if Flag == 0: +            Max_x += cnt +            Yoko.append(cnt) +        else: +            Max_y += cnt +            Tate.append(cnt) +        cnt = 0 +        Flag = Flag ^ 1 +# print(Yoko,Tate) +MAX_dpx = Max_x * 2 + 1 +dp = [0 for _ in range(MAX_dpx)] +dp[Max_x] = 1 +for i, x in enumerate(Yoko): +    p = [0 for _ in range(MAX_dpx)] +    p, dp = dp, p +    for j in range(MAX_dpx): +        if i == 0:  # i=0の時は右向きだけ +            if 0 <= j + x < MAX_dpx: +                dp[j + x] = max(dp[j + x], p[j]) +        else: +            if 0 <= j + x < MAX_dpx: +                dp[j + x] = max(dp[j + x], p[j]) +            if 0 <= j - x < MAX_dpx: +                dp[j - x] = max(dp[j - x], p[j]) +    # print(dp) +# print(dp) +# print(gx+Max_x,MAX_dpx) +if gx + Max_x >= MAX_dpx or gx + Max_x < 0 or dp[gx + Max_x] == 0: +    print("No") +    exit() +MAX_dpy = Max_y * 2 + 1 +dp = [0 for _ in range(MAX_dpy)] +dp[Max_y] = 1 +for i, y in enumerate(Tate): +    p = [0 for _ in range(MAX_dpy)] +    p, dp = dp, p +    for j in range(MAX_dpy): +        if 0 <= j + y < MAX_dpy: +            dp[j + y] = max(dp[j + y], p[j]) +        if 0 <= j - y < MAX_dpy: +            dp[j - y] = max(dp[j - y], p[j]) +    # print(dp) +# print(dp) +if gy + Max_y >= MAX_dpy or gy + Max_y < 0 or dp[gy + Max_y] == 0: +    print("No") +else: -else: -    print("No")