from collections import deque
X = str(input())
lx = len(X)
st = deque([])

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