#include <bits/stdc++.h>
using namespace std;
struct Solution {
  void solve(std::istream& in, std::ostream& out) {
    string s;
    in >> s;
    for (int i = 0; i < 100000; i++) {
      auto pos = s.find("SSSSSSSSTTTTTTTT");
      if (pos == string::npos) {
      } else {
        s.erase(pos, 16);
        continue;
      }
      pos = s.find("SSSSTTTT");
      if (pos == string::npos) {
      } else {
        s.erase(pos, 8);
        continue;
      }
      pos = s.find("SSTT");
      if (pos == string::npos) {
      } else {
        s.erase(pos, 4);
        continue;
      }
      pos = s.find("ST");
      if (pos == string::npos) {
        break;
      } else {
        s.erase(pos, 2);
      }
    }
    out << s.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;
}
