X = input()
st = [] # even: S, odd: T
if X[0]=="T":
    st.append(0)
tmp = X[0]
cnt = 1
for x in X[1:]:
    if x==tmp:
        cnt+=1
    else:
        st.append(cnt)
        tmp = x
        cnt = 1
else:
    if cnt>0:
        st.append(cnt)
if X[-1]=="S":
    st.append(0)
# print(st)

ans = 0
for i in range(len(st)-1):
    if i%2==0:
        ans += abs(st[i]-st[i+1])
print(ans)