string = list(input())

string_len = len(string)

string.append("0")
complete_control = 1

while complete_control:
    complete_control = 0

    for char in range(string_len):
        if string[char] == "S" and string[char + 1] == "T":
            del string[char]
            del string[char]
            string_len -=2

            complete_control = 1
            break



print(string_len)



