#include <bits/stdc++.h>
namespace Program {
using namespace std;
class Solver {
 private:
  string ST = "ST";
  string X;
  string a;

 public:
  Solver() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> X;
  };
  string Replace(string String1, string String2, string String3) {
    string::size_type Pos(String1.find(String2));
    while (Pos != string::npos) {
      String1.replace(Pos, String2.length(), String3);
      Pos = String1.find(String2, Pos + String3.length());
    }
    return String1;
  };
  void Solve() {
    a = X;
    int l = a.size();
    while (true) {
      a = Replace(a, ST, "");
      if (l == a.size()) break;
      l = a.size();
    }
    cout << l << "\n";
  };
};
}  // namespace Program
int main() {
  void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
  Program::Solver obj;
  (obj.*pSolve)();
  return 0;
}
