X = str(input())
X = X.replace("ST","")
lx = len(X)
st = []

for i in range(lx):
  if X[i] == "S":
    st.append("S")
  else:
    if "S" in st:
      st.pop()
    else:
      st = ["T"] + st
   
print(len(st))