#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    string str;
    in >> str;
    int size = 0;
    while (size != str.size()) {
      size = str.size();
      for (int i = 0; i + 1 < str.size(); i++) {
        if (str.substr(i, 2) == "ST") {
          string str2 = str.substr(0, i);
          if (i + 2 < str.size()) {
            str2 += str.substr(i + 2, str.size() - i - 2);
          }
          str = str2;
          break;
        }
      }
    }
    out << size << "\n";
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
