targ = input()
length = len(targ)
num = 0
while True:
    for num in range(length):
        if targ[num: num+2] == 'ST':
            targ = targ[max(num-2,0):num] + targ[num+2:]
            length -= 2
            break
    else:
        break
print(length)
    