s = input()
while 1:
    i = s.find('ST')
    if i > -1:
        cnt = 0
        for j in range(min(i, len(s)-2-i)):
            if s[i-j-1] == 'S' and s[i+j+2] == 'T':
                cnt += 1
            else:
                break
        s = s[:i-cnt] + s[i+cnt+2:]
    else:
        break
print(len(s))