#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;
const int INF = 1e8;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  while (true) {
    auto pos = s.find("ST");
    if (pos == std::string::npos) {
      break;
    }
    s = s.substr(0, pos) + s.substr(pos + 2, s.size() - pos - 2);
  }
  cout << s.size() << endl;
}
