#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  for (long long i = 0; i < (long long)(s.size()); i++) {
    for (long long j = 0; j < (long long)(s.size() - 1); j++) {
      if (s.at(j) == 'S' && s.at(j + 1) == 'T') {
        s = s.substr(0, j) + s.substr(j + 2);
      }
    }
  }
  cout << s.size() << endl;
}
