#--------------------------------------------------
import strutils, sequtils, math, algorithm, tables, sets, lists, intsets, critbits, future
let read* = iterator: string {.closure.} =
    while true: (for s in stdin.readLine.split: yield s)
proc scan(): int = read().parseInt
#--------------------------------------------------
var x = read()
var i = 0
while i < x.high:
    if x[i..i+1] == "ST":
        x.delete(i,i+1)
        i = max(i-1, 0)
    else:
        i += 1

echo x.len