input_string = raw_input()

s_num = 0
str_len = len(input_string)

for c in input_string:
    if c == 'S':
        s_num += 1

    elif c == 'T':
        if s_num > 0:
            s_num -= 1
            str_len -= 2

print str_len