X = input()
mLoop = 10 ** 1000
i = 0
while i < mLoop:
  p = X.find('ST')
  if p == -1:
    break
  q = p + 2
  p -= 1
  while p >= 0 and i < mLoop:
    if not(X[p] == 'S' and X[q] == 'T'):
      break
    p -= 1
    q += 1
    i += 1
  X = ''.join([X[:p + 1],X[q:]])
  i += 1

print(len(X))  