S = list(input())
cnt = len(S)
while len(S) > 0:
  i = 0
  while i < len(S)-1:
    if S[i] == "S" and S[i+1] == "T":
      S.pop(i)
      S.pop(i+1)
    i += 1
  if cnt == len(S):
    print(len(S))
    exit()
  cnt = len(S)
print(len(S))