use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $x = <STDIN>);
while ($x=~/SSSSSSSSTTTTTTTT/) {
  $x =~ s/SSSSSSSSTTTTTTTT//g;
}
while ($x=~/SSSSTTTT/) {
  $x =~ s/SSSSTTTT//g;
}
while ($x=~/SSTT/) {
  $x =~ s/SSTT//g;
}
while ($x=~/ST/) {
  $x =~ s/ST//g;
}
say length($x);