'use strict';

const S = "S";

const process = (input) => {
    let finalLength = input.length;
    let currentSCount = 0;

    for (let i=0, length = input.length; i<length; i++) {
        if (input.charAt(i) === S) {
            currentSCount++;
        } else {
            if (currentSCount > 0) {
                currentSCount--;
                finalLength-=2;
            }
        }
    }

    console.log(finalLength);
}

process(require("fs").readFileSync("/dev/stdin", "utf8"));