import algorithm, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode
 
macro unpack*(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  if NimMinor <= 17:
    for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
  else:
    for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
 
template input*(typ: typedesc, cnt: Natural = 0): untyped =
  let line = stdin.readLine.split(" ")
  when cnt == 0:
    when typ is int:    @[0]   & line.map(parseInt)
    elif typ is float:  @[0.0] & line.map(parseFloat)
    elif typ is string: @["#"] & line
  else:
    when typ is int:    line.map(parseInt).unpack(cnt)
    elif typ is float:  line.map(parseFloat).unpack(cnt)
    elif typ is string: line.unpack(cnt)
 
# -------------------------------------------------- #

var X = input(string)
var s, t = 0
for x in X:
  if x == 'S':
    s += 1
  elif x == 'T':
    if s > 0:
      s -= 1
    else:
      t += 1
echo s + t