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 = eval(input())

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



X_move = [len(s) for s in S.split("T")[::2]]

Y_move = [len(s) for s in S.split("T")[1::2]]



X_reached = {X_move.pop(0)}

Y_reached = {0}



for x in X_move:

    tmp = set()

    for nx in X_reached:

        tmp.add(nx + x)

        tmp.add(nx - x)

    X_reached = tmp



for y in Y_move:

    tmp = set()

    for ny in Y_reached:

        tmp.add(ny + y)

        tmp.add(ny - y)

    Y_reached = tmp



print(("Yes" if (X in X_reached) and (Y in Y_reached) else "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 = eval(input())
X, Y = list(map(int, input().split()))
X_move = [len(s) for s in S.split("T")[::2]]
Y_move = [len(s) for s in S.split("T")[1::2]]
X_reached = {X_move.pop(0)}
Y_reached = {0}
for x in X_move:
    tmp = set()
    for nx in X_reached:
        tmp.add(nx + x)
        tmp.add(nx - x)
    X_reached = tmp
for y in Y_move:
    tmp = set()
    for ny in Y_reached:
        tmp.add(ny + y)
        tmp.add(ny - y)
    Y_reached = tmp
print(("Yes" if (X in X_reached) and (Y in Y_reached) else "No"))

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