import sys
import string
import re
input = lambda: sys.stdin.readline()

def main(s):
    return s.replace("ST","")

if __name__ == '__main__':
    cnt  = 0
    s = input()
    k = ""
    flag = False
    ans = main(s)
    cnt = ans.count("ST")
    if cnt != 0:
        k = main(ans)
        print(len(k) - 1)
    else:
        # print(0)
        print(len(ans) - 1)
