x = list(input())

before = ''
i = 0
while True:
    flag = 1
    for s in x:
        if(before == 'S' and s == 'T'):
            x.remove(x[i])
            x.remove(x[i+1])
            flag = 0
            break
        i+=1
        before = s
    if(flag == 0):
        break

print(len(x))