x = input()

while True:
    n = len(x)
    fl = 0
    for i in range(n-1):
        if x[i] == "S" and x[i+1] == "T":
            x = x[:i] + x[i+2:]
            fl = 1
            break
            
    if fl == 0:
        break
        
print(len(x))