package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := readR()

	for i := 0; i < len(s)-1; i++ {
		if s[i] == 'S' && s[i+1] == 'T' {
			s = rem(s, i)
			i = -1
		}
	}

	fmt.Println(len(s))

}

func rem(a []rune, b int) []rune {
	return append(a[:b], a[b+2:]...)
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}
