X = input().strip()
flag = 0
cntS = 0
cntT = 0
num = 0
for i in range(len(X)):
    if X[i]=="S":
        if flag==0:
            num += min(cntS,cntT)
            cntS = 0
            cntT = 0
            flag = 1
        cntS += 1
    else:
        if flag==1:
            flag = 0
        cntT += 1
num += min(cntS,cntT)
print(len(X)-2*num)      