string = list(input())


complete_control = False
max_num = 10**10000
string_len = len(string)
while max_num: 
    temp_index = 0
    for char in range(string_len):
        if string[char] == "S" and string[char + 1] == "T":
            temp_index = char
            string_len -=2
            break
        else:
            complete_control = True
        
    del string[temp_index + 1]
    del string[temp_index]

    if complete_control:
        break
    max_num -= 1
    

print(string_len)
