import sequtils, algorithm,strutils,sets, math

proc solve():int=
  var x = stdin.readline
  var result = x.len div 2
  var idx = 0
  var scount = 0
  while scount < x.len div 2:
    #echo x[idx], ", ", result
    if x[idx] == 'T':
      scount+=1
    elif x[idx] == 'S':
      result-=1
    idx+=1
  return result*2










echo solve()