#include <bits/stdc++.h>
using namespace std;
string s;
int sumt, sums, sum;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S')
      sums++;
    else if (sums)
      sumt++;
    if (sums == sumt) {
      sum += sums + sumt;
      sums = sumt = 0;
    }
  }
  cout << n - sum << endl;
  return 0;
}
