#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  string x;
  while (getline(cin, x)) {
    int length = 0;
    bool s = false;
    unsigned int count = 0;
    for (unsigned int i = 0; i < x.size(); ++i) {
      if (!s) {
        if (x[i] == 'S') {
          s = true;
        }
      } else {
        if (x[i] == 'T') {
          length -= 2;
          ++count;
          unsigned int counter = 0;
          for (unsigned int j = i - 1; j > 0; --j) {
            if (x[j] == 'T') {
              s = false;
              break;
            } else {
              ++counter;
              if (counter > count) {
                s = true;
                break;
              }
            }
            s = false;
          }
        }
      }
      ++length;
    }
    cout << length << endl;
  }
  return 0;
}
