import re

def cal():
    x = input()
    while True:
        pre = len(x)
        x = re.sub('SSTT', '', x)
        x = re.sub('ST', '', x)
        if len(x) == pre:
            break
    print(len(x))

cal()
