x=input()
judge = True
while judge:
    for i in range(len(x)):
        if x[i:i+2] == "ST" :
            x=x[:i] + x[i+2:]
            break
    if "ST" not in x : 
        judge=False
        print(len(x))