x = list(input())
while x[0:int(len(x)/2)] != ['T'] * int(len(x)/2):
    for i in range(len(x)-1):
        if x[i] == 'S' and x[i+1] == 'T':
            x[i], x[i+1] = '', ''
    x.remove('')
print(len(x))