from os import sys


X = input()

within_seq = False
start = -1 # start index of ST string to be removed
res = X
ST_found = False # was 'ST' ever found in the curr loop?

if len(X) < 2:
    print(0)
    sys.exit()
    
while True:
    i = 0
    while i < len(res):     
        c = res[i]    
        if not within_seq:
            if c == 'S':   
                within_seq = True
                start = i
        else:
            if c == 'S':
                start = i
            elif c == 'T':
                within_seq = False
                ST_found = True
                res = res[:start] + res[start+2:]
        i += 1

    if len(res) == 0 or not ST_found:
        break
    ST_found = False
    within_seq = False
 
print(len(res))
