#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int ss = (str[0] == 'S' ? 1 : 0), l = str.length();
  for (int i = 1; i < str.length(); i++) {
    if (str[i] == 'S') {
      if (str[i - 1] == 'S') {
        ss++;
      } else {
        ss = 1;
      }
    } else {
      if (ss) {
        l -= 2;
        ss--;
      }
    }
  }
  cout << l << endl;
  return 0;
}
