A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of "F" (move forward) and "T" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be "Yes" if the objective is achievable, and "No" if it is not. Sample inputs and outputs are provided to illustrate the problem.

# Buggy version:
s=list(input())
x,y=map(int,input().split())
f=0
t=0
s.append('T')
n=len(s)
xl=[]
yl=[]
for i in range(n):
    if s[i]=='F':
        f+=1
    else:
        if t%2==0:
            xl.append(f)
        else:
            yl.append(f)
        f=0
        t+=1
def solve(x,l):
    n=len(l)
    k=2*8000+1
    dp=[[-1 for p in range(k)] for q in range(n+1)]
    dp[0][k//2]=0
    for i in range(1,n+1):
        for j in range(k):
            if dp[i][j]==i:
                dp[i+1][j-l[i]]=i
    if dp[n][x]>0:
        return True
    else:
        return False
if solve(x,xl) and solve(y,yl):
    print('Yes')
else:
    print('No')

# Fixed version:
s=list(input())
x,y=map(int,input().split())
f=0
t=0
s.append('T')
n=len(s)
xl=[]
yl=[]
for i in range(n):
    if s[i]=='F':
        f+=1
    else:
        if f>0:
            if t%2==0:
                if t==0:
                    x-=f
                else:
                    xl.append(f)
            else:
                yl.append(f)
            f=0
        t+=1
def solve(x,l):
    n=len(l)
    k=2*8000+1
    dp=[[-1 for p in range(k)] for q in range(n+1)]
    dp[0][k//2]=0
    for i in range(1,n+1):
        for j in range(k):
            if dp[i-1][j]>=0:
                dp[i][j-l[i-1]]=1
                dp[i][j+l[i-1]]=1
                #print(j)
    if dp[-1][x+k//2]>=0:
        return True
    else:
        return False
if solve(x,xl) and solve(y,yl):
    print('Yes')
else:
    print('No')
#print(xl,yl)

# Buggy version:
import sys
s=input()
x,y=map(int,input().split())
s=s+'T'
dp=[[] for i in range(2)]
t=0
buf=0
for i in range(len(s)):
    if s[i]=='F':
        buf+=1
    else:
        if buf!=0:
            dp[t].append(buf)
            buf=0
        t=1-t
#print(s)  
#print(dp)
xb=1<<(len(s))
yb=1<<(len(s))

for i in range(len(dp[0])):
    xb=(xb<<dp[0][i])|(xb>>dp[0][i])
if xb & 1<<(len(s)+x)==0:
    #print('No')
    sys.exit()
for i in range(len(dp[1])):
    yb=(yb<<dp[1][i])|(yb>>dp[1][i])

if yb & 1<<(len(s)+y)==0:
    print('No')
    sys.exit()
print('Yes')

# Fixed version:
import sys
s=input()
x,y=map(int,input().split())
s=s+'T'
dp=[[] for i in range(2)]
t=0
buf=0
for j in range(len(s)):
    if s[j]=='T':
        break

for i in range(j,len(s)):
    if s[i]=='F':
        buf+=1
    else:
        if buf!=0:
            dp[t].append(buf)
            buf=0
        t=1-t
#print(s)  
#print(dp)
xb=1<<(len(s)+j)
yb=1<<(len(s))

for i in range(len(dp[0])):
    xb=(xb<<dp[0][i])|(xb>>dp[0][i])
if xb & 1<<(len(s)+x)==0:
    print('No')
    sys.exit()
for i in range(len(dp[1])):
    yb=(yb<<dp[1][i])|(yb>>dp[1][i])

if yb & 1<<(len(s)+y)==0:
    print('No')
    sys.exit()
print('Yes')

# Buggy version:
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
# 最初は右に行くしかない
dp_x = {m[0]}
for i in m[2::2]:
    new_dp = set()
    for v in dp_x:
        new_dp += {v + i, v - i}
    dp_x = new_dp

dp_y = {0}
for i in m[1::2]:
    new_dp = set()
    for v in dp_y:
        new_dp += {v + i, v - i}
    dp_y = new_dp

print('Yes' if x in dp_x and y in dp_y else 'No')

print(dp_x)
print(dp_y)

# Fixed version:
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
# 最初は右に行くしかない
dp_x = {m[0]}
for i in m[2::2]:
    new_dp = set()
    for v in dp_x:
        new_dp |= {v + i, v - i}
    dp_x = new_dp

dp_y = {0}
for i in m[1::2]:
    new_dp = set()
    for v in dp_y:
        new_dp |= {v + i, v - i}
    dp_y = new_dp

print('Yes' if x in dp_x and y in dp_y else 'No')

# Buggy version:
import sys

s = input().split("T")
x, y = map(int, input().split())
x -= len(s[0])
s.pop(0)

list_yoko = [len(s[i]) for i in range(1, len(s), 2)]
list_tate = [len(s[i]) for i in range(0, len(s), 2)]

set_yoko = {list_yoko[0], -list_yoko[0]}
set_tate = {list_tate[0], -list_tate[0]}

for i in list_yoko[1:]:
	sy = set()
	for j in set_yoko:
		sy |= {j + i, j - i}
	set_yoko = sy

for i in list_tate[1:]:
	st = set()
	for j in set_tate:
		st |= {j + i, j - i}
	set_tate = st

if (x in sy) and (y in st):
	print("Yes")
else:
	print("No")

# Fixed version:
s = input().split("T")
x, y = map(int, input().split())
x -= len(s[0])
s.pop(0)

list_yoko = [len(s[i]) for i in range(1, len(s), 2)]
list_tate = [len(s[i]) for i in range(0, len(s), 2)]

if list_yoko == []:
	list_yoko = [0]

if list_tate == []:
	list_tate = [0]
	
set_yoko = {list_yoko[0], -list_yoko[0]}
set_tate = {list_tate[0], -list_tate[0]}

for i in list_yoko[1:]:
	sy = set()
	for j in set_yoko:
		sy |= {j + i, j - i}
	set_yoko = sy

for i in list_tate[1:]:
	st = set()
	for j in set_tate:
		st |= {j + i, j - i}
	set_tate = st

if (x in set_yoko) and (y in set_tate):
	print("Yes")
else:
	print("No")

# Buggy version:
def f(m, s, g):
    for i in m:
        if s > g:
            s -= i
        else:
            s += i
    return s == g
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
print(m)
if (f(sorted(m[::2][1::])[::-1], m[0], x)
        and f(sorted(m[1::2])[::-1], 0, y)):
    print('Yes')
else:
    print('No')

# Fixed version:
def f(m, s, g):
    for i in m:
        if s > g:
            s -= i
        else:
            s += i
    return s == g
s = input()
x, y = map(int, input().split())
m = list(map(len, s.split('T')))
if (f(sorted(m[::2][1::])[::-1], m[0], x)
        and f(sorted(m[1::2])[::-1], 0, y)):
    print('Yes')
else:
    print('No')