let
  X = readLine stdin
var
  a = newSeq[char]()

for v in X:
  case v
  of 'S':
    insert a, v
  of 'T':
    if a.len == 0 or a[0] == 'T':
      insert a, v
    elif a[0] == 'S':
      delete a, 0
  else:
    discard

echo a.len
