x = input()
l = len(x)

before = l

for i in range(100000):
    x = x.replace("ST", "", 100000)
    current = len(x)
    #print(x)
    if current == 0 or current == before:
        break
    before = current

print(len(x))
