#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  int c = 0;
  while (a != -1) {
    if (s.size() >= 6) {
      c = s.find("SSSTTT");
      if (c != -1) {
        s.erase(c, 6);
      }
    }
    if (s.size() >= 4) {
      b = s.find("SSTT");
      if (b != -1) {
        s.erase(b, 4);
      }
    }
    a = s.find("ST");
    if (a != -1) {
      s.erase(a, 2);
    }
  }
  cout << s.size() << endl;
}
