<?php
$input = trim(fgets(STDIN));
$next = $input;
while(true){
    $pos = strpos($next,"ST");
    if($pos===false){
        break;
    }
    $next = str_replace("ST","",$next);
}
echo strlen($next);
?>