S = list(input().split("T"))

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



X_act = [len(i) for i in S[::2]]

Y_act = [len(i) for i in S[1::2]]



X_reached = {X_act[0]}

del X_act[0]

for xa in X_act:

    tmp = set()

    for xr in X_reached:

        tmp.add(xr+xa)

        tmp.add(xr-xa)

    X_reached = tmp



Y_reached = {0}

for ya in Y_act:

    tmp = set()

    for yr in Y_reached:

        tmp.add(yr+ya)

        tmp.add(yr-ya)

    Y_reached = tmp



if x in X_reached and y in Y_reached:

    print("Yes")

else:

    print("No")
S = [len(s) for s in input().split("T")]

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



# X方向・Y方向の移動成分

X_move = S[2::2]

Y_move = S[1::2]



# X方向・Y方法の到達可能な場所

X_reached = {S[0]}

Y_reached = {0}



# 到達可能な場所を計算

for xm in X_move:

    tmp = set()

    for xr in X_reached:

        tmp.add(xr + xm)

        tmp.add(xr - xm)

    X_reached = tmp



for ym in Y_move:

    tmp = set()

    for yr in Y_reached:

        tmp.add(yr + ym)

        tmp.add(yr - ym)

    Y_reached = tmp



print(("Yes" if (X in X_reached and Y in Y_reached) else "No"))

S = list(input().split("T"))
x, y = list(map(int, input().split()))
X_act = [len(i) for i in S[::2]]
Y_act = [len(i) for i in S[1::2]]
X_reached = {X_act[0]}
del X_act[0]
for xa in X_act:
    tmp = set()
    for xr in X_reached:
        tmp.add(xr + xa)
        tmp.add(xr - xa)
    X_reached = tmp
Y_reached = {0}
for ya in Y_act:
    tmp = set()
    for yr in Y_reached:
        tmp.add(yr + ya)
        tmp.add(yr - ya)
    Y_reached = tmp
if x in X_reached and y in Y_reached:
    print("Yes")
else:
    print("No")

S = [len(s) for s in input().split("T")]
X, Y = list(map(int, input().split()))
# X方向・Y方向の移動成分
X_move = S[2::2]
Y_move = S[1::2]
# X方向・Y方法の到達可能な場所
X_reached = {S[0]}
Y_reached = {0}
# 到達可能な場所を計算
for xm in X_move:
    tmp = set()
    for xr in X_reached:
        tmp.add(xr + xm)
        tmp.add(xr - xm)
    X_reached = tmp
for ym in Y_move:
    tmp = set()
    for yr in Y_reached:
        tmp.add(yr + ym)
        tmp.add(yr - ym)
    Y_reached = tmp
print(("Yes" if (X in X_reached and Y in Y_reached) else "No"))

-S = list(input().split("T")) -x, y = list(map(int, input().split())) -X_act = [len(i) for i in S[::2]] -Y_act = [len(i) for i in S[1::2]] -X_reached = {X_act[0]} -del X_act[0] -for xa in X_act: +S = [len(s) for s in input().split("T")] +X, Y = list(map(int, input().split())) +# X方向・Y方向の移動成分 +X_move = S[2::2] +Y_move = S[1::2] +# X方向・Y方法の到達可能な場所 +X_reached = {S[0]} +Y_reached = {0} +# 到達可能な場所を計算 +for xm in X_move: -        tmp.add(xr + xa) -        tmp.add(xr - xa) +        tmp.add(xr + xm) +        tmp.add(xr - xm) -Y_reached = {0} -for ya in Y_act: +for ym in Y_move: -        tmp.add(yr + ya) -        tmp.add(yr - ya) +        tmp.add(yr + ym) +        tmp.add(yr - ym) -if x in X_reached and y in Y_reached: -    print("Yes") -else: -    print("No") +print(("Yes" if (X in X_reached and Y in Y_reached) else "No"))