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

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

$ans = 0;

fscanf(STDIN, "%s", $X);
$len = strlen($X);

if (preg_match("/^S+T+$/"), $X) {
	echo strlen($X / 2) . PHP_EOL;
	exit;
}

while (preg_match("/ST/", $X)) {
	$X = str_replace("ST", "", $X);
	$ans++;
}

echo strlen($X) . PHP_EOL;
