import re

def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]


pattern="ST"


cnt=10**10000
for i in range(cnt):
    
    if x.count("ST")>0:

        x = re.sub(pattern, "", x)
    else:
        
        break
        
print(len(x))
