<?php

fscanf(STDIN, "%s", $a);

function delST(&$subject) {
	if (preg_match("/ST/", $subject)) {
		$subject = preg_replace("/ST/", "", $subject, 1);
		return delST($subject);
	} else {
		return $subject;
	}
}

if ($a) {
	echo strlen(delST($a));
} else {
	echo 0;
}