def sol():
  ti = 0
  ans = lenX
  for i in range(lenX//2):
    while S[i]>=T[ti]:
      ti += 1
      if ti>=lenX//2:
        return ans
    ans -= 2    
  return ans

X = input()
lenX = len(X)
S = []
T = []
for i,x in enumerate(X):
  if x == 'S':S.append(i)
  else:T.append(i)

print(sol())