package main

import (
	"fmt"
)

func main() {
	var X string
	fmt.Scan(&X)
	x := []byte(X)
	st := []byte("ST")
	for len(x) > 1 {
		change := false
		// log.Println(string(x))
		for i := 0; i < len(x)-1; i++ {
			if x[i] == st[0] && x[i+1] == st[1] {
				x = append(x[:i], x[i+2:]...)
				change = true
				break
			}
		}
		if !change {
			break
		}
	}
	fmt.Println(len(x))
}
