const process = (input) => {
    const index = input.indexOf("ST");
 
    if (index > -1) {
        return process(input.replace(/ST/g, ""));
    } else {
        return input;
    }
};
 
const Main = (input) => {
	console.log(process(input).length);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));