my $x = <>;
chomp($x);

my $count = 0;
for my $i (0..length($x)-1) {
    my $c = substr($x, $i, 1);
    if ($c eq 'S') {
        ++$count;
    } elsif ($c eq 'T') {
        if ($count == 0) {
            ++$count;
        } else {
            --$count;
        }
    }
}
print $count, "\n";