X = list(input())
N = len(X)
s = 0
t = 0
sold = 0
ans = N
for i in range(N):
  if X[i] == 'S':
    if s == 0:
      ans -= 2 * min(sold, t)
      sold = 0
      t = 0
    s += 1
  elif t == 0:
    sold = s
    s = 0
    t += 1
  else:
    t += 1
if s == 0:
  ans -= 2 * min(sold, t)
print(ans)