package main

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

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 4096)
    X := readLine(reader)
    arr := []byte(X)
    length := len(arr)
    var flag int = 0
    var cnt int = 0

    for i := length - 1; i >= 0; i-- {
        if flag == 0 {
            if string(arr[i]) == "T" {
                flag = 1
            }
        } else {
            if string(arr[i]) == "S" {
                cnt++
            }
        }
    }

    fmt.Println(length - cnt*2)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}