string = list(input())

string_len = len(string)

string.append("0")
complete_control = 1

while complete_control:
    complete_control = 0
    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 = 1
            break
    try:
        del string[temp_index]
        del string[temp_index]
    except IndexError:
        break


print(string_len)
