x = input()
s_count = x.count('S')
t_count = x.count('T')
count = 0
for i in range(len(x)):
    if s_count == 0 or t_count == 0:
        break
    if x[i]=='S':
        s_count -= 1
        if t_count > 0:
            count += 1
    else:
        t_count -= 1
print(len(x)-count*2)
