process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    main(chunk.trim());
});

function main(chunk){
    var ans = chunk.length;
    
    var line = chunk.split("");
    
    var s_cnt = 0;
    for(var i in line){
        switch(line[i]){
        case 'S':
            s_cnt++;
            break;
        case 'T':
            if(s_cnt>0){
                s_cnt--;
                ans-=2;
            }
            break;
        }
    }
    console.log(ans);
}

