package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

func scanBytes(scanner *bufio.Scanner) (bs []byte) {
	if scanner.Scan() {
		return scanner.Bytes()
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	x := scanBytes(scanner) // 2 <= |x| <= 200,000
	length := len(x)
	list := list.New()
	for _, b := range x {
		if b == 'S' || list.Len() == 0 {
			list.PushBack(b) // 'S' or 'T'
			continue
		}
		// b == 'T':
		if back := list.Back(); back.Value.(byte) == 'S' {
			list.Remove(back)
			length -= 2
			continue
		}
		list.PushBack(b)
	}
	fmt.Println(length)
}
