if __name__ == "__main__":

    s = eval(input())



    ans = ''



    for ss in s:

        if ss == 'S':

            ans += ss

        else:

            if len(ans) == 0:

                ans += ss

            elif ans[len(ans) - 1] == 'S':

                ans = ans[:-1]

            elif ans[len(ans) - 1] == 'T':

                ans += ss



    print((len(ans)))

if __name__ == "__main__":

    x = eval(input())



    count = 0

    ans = len(x)

    for i in range(len(x)):

        if x[i] == 'S':

            count += 1

        elif count > 0 and x[i] == 'T':

            ans -= 2

            count -= 1

        else:

            count = 0



    print(ans)

if __name__ == "__main__":
    s = eval(input())
    ans = ""
    for ss in s:
        if ss == "S":
            ans += ss
        else:
            if len(ans) == 0:
                ans += ss
            elif ans[len(ans) - 1] == "S":
                ans = ans[:-1]
            elif ans[len(ans) - 1] == "T":
                ans += ss
    print((len(ans)))

if __name__ == "__main__":
    x = eval(input())
    count = 0
    ans = len(x)
    for i in range(len(x)):
        if x[i] == "S":
            count += 1
        elif count > 0 and x[i] == "T":
            ans -= 2
            count -= 1
        else:
            count = 0
    print(ans)

-    s = eval(input()) -    ans = "" -    for ss in s: -        if ss == "S": -            ans += ss +    x = eval(input()) +    count = 0 +    ans = len(x) +    for i in range(len(x)): +        if x[i] == "S": +            count += 1 +        elif count > 0 and x[i] == "T": +            ans -= 2 +            count -= 1 -            if len(ans) == 0: -                ans += ss -            elif ans[len(ans) - 1] == "S": -                ans = ans[:-1] -            elif ans[len(ans) - 1] == "T": -                ans += ss -    print((len(ans))) +            count = 0 +    print(ans)