import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.next();

        while (str.matches(".*ST.*")){
            str = str.replaceAll("ST", "");
        }
        System.out.println(str.length());
    }
}