#coding:utf-8
X = input()
ans = 0
cnt = 0
old = ""
for x in X:
    if x=="S":
        if (old != "S"):
            cnt = 0
        cnt+=1
    else:
        if (cnt>0):
            cnt-=1
            ans+=1
    old = x
print (len(X)-2*ans)