<?php
/*
    URL    : http://agc005.contest.atcoder.jp/tasks/agc005_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%s", $X);
$lenX = strlen($X);
// echo $X . PHP_EOL;
$W = "";

for ($i = 0; $i < $lenX; $i++) {
	if ($X[0] === "T" && $W[strlen($W)-1] === "S") {
		$W = substr($W, 0, strlen($W) - 1);
	} else {
		$W .= $X[0];
	}
	$X = substr($X, 1);		
	// echo "{$W} {$X}\n";
}

// echo $W . PHP_EOL;
echo strlen($W) . PHP_EOL;
