x = input()
i = len(x)
cnt = 0

while True:
    if cnt > 
    
    p = x.find('ST')
    if p != -1:
        cnt += 1
    else:
        break
    
    n = p
    while True:
        if len(x) -1 > 0:
            
            if x[n-1] == 'S':
                cnt += 1
                n -= 1
            else:
                break
    x = x[:p] + x[p+2:]

print(len(x))