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

chomp (my $x = <STDIN>);

my $ans = length $x;
my ($sc, $tc);
for my $i (0..length($x)) {
  if ($i == length($x)) {
    if ($sc > 0 && $tc > 0) {
      $ans -= 2 * min($sc, $tc);
    }
  } elsif (substr($x, $i, 1) eq 'S') {
    if ($sc > 0 && $tc > 0) {
      $ans -= 2 * min($sc, $tc);
      $sc = 0;
      $tc = 0;
    }
    $sc++;
  } else {
    $tc++
  }
}
say $ans;