def main():

    s = str(eval(input()))

    n = len(s)

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



    dx = []

    dy = []

    dir = 0

    cnt = 0

    for i in range(n):

        if s[i] == 'F':

            cnt += 1

        else:

            if dir%2 == 0:

                dx.append(cnt)

                cnt = 0

                dir += 1

            else:

                dy.append(cnt)

                cnt = 0

                dir += 1

    else:

        if dir%2 == 0:

            dx.append(cnt)

        else:

            dy.append(cnt)



    dpx = [0]*(len(dx)+1)

    dpy = [0]*(len(dy)+1)



    import numpy as np

    D = 2*n+1

    dpx[0] = np.zeros(D, np.bool)

    dpy[0] = np.zeros(D, np.bool)

    dpx[0][n] = 1

    dpy[0][n] = 1



    for i in range(len(dx)):

        d = dx[i]

        if i == 0:

            b = np.zeros(D, np.bool)

            b[d:] |= dpx[i][:D-d]

        else:

            b = np.zeros(D, np.bool)

            b[d:] |= dpx[i][:D-d]

            b[:D-d] |= dpx[i][d:]

        dpx[i+1] = b



    for i in range(len(dy)):

        d = dy[i]

        b = np.zeros(D, np.bool)

        b[d:] |= dpy[i][:D-d]

        b[:D-d] |= dpy[i][d:]

        dpy[i+1] = b



    if dpx[-1][n+x] and dpy[-1][n+y]:

        print('Yes')

    else:

        print('No')



if __name__ == '__main__':

    main()

def main():



    s = str(eval(input()))

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



    n = len(s)



    dir = 1

    dx = []

    dy = []

    cnt = 0

    for i in range(n):

        if s[i] == 'F':

            cnt += 1

        else:

            if dir == 1:

                dx.append(cnt)

                cnt = 0

                dir = -1

            else:

                dy.append(cnt)

                cnt = 0

                dir = 1

    else:

        if dir == 1:

            dx.append(cnt)

        else:

            dy.append(cnt)

    #print(dx)

    #print(dy)

    D = 8000*2+1



    import numpy as np

    dpx = [0]*(len(dx)+1)

    dpy = [0]*(len(dy)+1)

    dpx[0] = np.zeros(D, np.bool)

    dpy[0] = np.zeros(D, np.bool)

    dpx[0][8000] = 1

    dpy[0][8000] = 1

    for i, d in enumerate(dx):

        if i == 0:

            b = np.zeros(D, np.bool)

            b[d:] |= dpx[i][:D-d]

            dpx[i+1] = b

        else:

            b = np.zeros(D, np.bool)

            b[d:] |= dpx[i][:D-d]

            b[:D-d] |= dpx[i][d:]

            dpx[i+1] = b



    for i, d in enumerate(dy):

        b = np.zeros(D, np.bool)

        b[d:] |= dpy[i][:D-d]

        b[:D-d] |= dpy[i][d:]

        dpy[i+1] = b



    if dpx[-1][8000+x] == 1 and dpy[-1][8000+y] == 1:

        print('Yes')

    else:

        print('No')



if __name__ == '__main__':

    main()

def main():
    s = str(eval(input()))
    n = len(s)
    x, y = list(map(int, input().split()))
    dx = []
    dy = []
    dir = 0
    cnt = 0
    for i in range(n):
        if s[i] == "F":
            cnt += 1
        else:
            if dir % 2 == 0:
                dx.append(cnt)
                cnt = 0
                dir += 1
            else:
                dy.append(cnt)
                cnt = 0
                dir += 1
    else:
        if dir % 2 == 0:
            dx.append(cnt)
        else:
            dy.append(cnt)
    dpx = [0] * (len(dx) + 1)
    dpy = [0] * (len(dy) + 1)
    import numpy as np

    D = 2 * n + 1
    dpx[0] = np.zeros(D, np.bool)
    dpy[0] = np.zeros(D, np.bool)
    dpx[0][n] = 1
    dpy[0][n] = 1
    for i in range(len(dx)):
        d = dx[i]
        if i == 0:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][: D - d]
        else:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][: D - d]
            b[: D - d] |= dpx[i][d:]
        dpx[i + 1] = b
    for i in range(len(dy)):
        d = dy[i]
        b = np.zeros(D, np.bool)
        b[d:] |= dpy[i][: D - d]
        b[: D - d] |= dpy[i][d:]
        dpy[i + 1] = b
    if dpx[-1][n + x] and dpy[-1][n + y]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

def main():
    s = str(eval(input()))
    x, y = list(map(int, input().split()))
    n = len(s)
    dir = 1
    dx = []
    dy = []
    cnt = 0
    for i in range(n):
        if s[i] == "F":
            cnt += 1
        else:
            if dir == 1:
                dx.append(cnt)
                cnt = 0
                dir = -1
            else:
                dy.append(cnt)
                cnt = 0
                dir = 1
    else:
        if dir == 1:
            dx.append(cnt)
        else:
            dy.append(cnt)
    # print(dx)
    # print(dy)
    D = 8000 * 2 + 1
    import numpy as np

    dpx = [0] * (len(dx) + 1)
    dpy = [0] * (len(dy) + 1)
    dpx[0] = np.zeros(D, np.bool)
    dpy[0] = np.zeros(D, np.bool)
    dpx[0][8000] = 1
    dpy[0][8000] = 1
    for i, d in enumerate(dx):
        if i == 0:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][: D - d]
            dpx[i + 1] = b
        else:
            b = np.zeros(D, np.bool)
            b[d:] |= dpx[i][: D - d]
            b[: D - d] |= dpx[i][d:]
            dpx[i + 1] = b
    for i, d in enumerate(dy):
        b = np.zeros(D, np.bool)
        b[d:] |= dpy[i][: D - d]
        b[: D - d] |= dpy[i][d:]
        dpy[i + 1] = b
    if dpx[-1][8000 + x] == 1 and dpy[-1][8000 + y] == 1:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

+    x, y = list(map(int, input().split())) -    x, y = list(map(int, input().split())) +    dir = 1 -    dir = 0 -            if dir % 2 == 0: +            if dir == 1: -                dir += 1 +                dir = -1 -                dir += 1 +                dir = 1 -        if dir % 2 == 0: +        if dir == 1: +    # print(dx) +    # print(dy) +    D = 8000 * 2 + 1 +    import numpy as np + -    import numpy as np - -    D = 2 * n + 1 -    dpx[0][n] = 1 -    dpy[0][n] = 1 -    for i in range(len(dx)): -        d = dx[i] +    dpx[0][8000] = 1 +    dpy[0][8000] = 1 +    for i, d in enumerate(dx): +            dpx[i + 1] = b -        dpx[i + 1] = b -    for i in range(len(dy)): -        d = dy[i] +            dpx[i + 1] = b +    for i, d in enumerate(dy): -    if dpx[-1][n + x] and dpy[-1][n + y]: +    if dpx[-1][8000 + x] == 1 and dpy[-1][8000 + y] == 1: