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