#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sN = 0;
  int tN = 0;
  for (int i = s.length() - 1; i >= 0; i--) {
    if (s[i] == 'S') {
      if (tN > 0) {
        tN--;
      } else {
        sN++;
      }
    } else {
      tN++;
    }
    if (tN >= sN) {
      cout << sN * 2 << endl;
      break;
    }
  }
  return 0;
}
