#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long n = s.size();
  for (long long i = 0; i < n; ++i) {
    if (s[i] == 'S') {
      if (s[i + 1] == 'T') {
        s.erase(i, 2);
        i = -1;
      }
    }
  }
  n = s.size();
  cout << n << endl;
}
