import sys
input = sys.stdin.readline
S = list(input())[: -1]
s = 0
t = 0
res = len(S)
if S[0] == "S": s += 1
for i in range(1, len(S)):
  if S[i] == "S":
    if t == 1:
      s = 0
      t = 0
    s += 1
  else:
    if s > 0:
      res -= 2
      s -= 1
      t = 1
print(res)