#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  bool h = true;
  int reg = 0;
  int c_s = 0;
  int c_t = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (h) {
      if (s[i] == 'S') {
        c_s++;
        continue;
      } else {
        h = false;
        c_t++;
      }
    } else {
      if (s[i] == 'S') {
        reg++;
        c_s++;
      } else {
        c_t++;
        continue;
      }
    }
  }
  int k = min(c_s, c_t);
  k = s.size() - 2 * k;
  cout << max({(int)s.size() - reg * 2, 0, k}) << endl;
}
