string = list(input())



max_num = 10**10000
string_len = len(string)

while max_num:
    complete_control = 1
    temp_index = 0
    for char in range(string_len):
        if string[char] == "S" and string[char + 1] == "T":
            temp_index = char
            string_len -=2
            complete_control = 0
            break

    if complete_control:
        break
    
    del string[temp_index]
    del string[temp_index]


    max_num -= 1
    

print(string_len)
