x=input()
num_t=0
num_s=0
for i in range(len(x)//2):
    if x[i]=='T':
        num_t+=1
    else:
        break
for i in range(len(x)//2):
    if x[-1-i]=='S':
        num_s+=1
    else:
        break
print(max([num_t,num_s])*2)

