#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const bool DEBUG = false;
string replaceAll(string s, string f, string t) {
  string::size_type pos = s.find(f);
  while (pos != string::npos) {
    s.replace(pos, f.size(), t);
    pos = s.find(f, pos + t.size());
  }
  return s;
}
signed main() {
  string X, Y;
  cin >> X;
  while (true) {
    Y = replaceAll(X, "ST", "");
    if (DEBUG) {
      cerr << "Y"
           << " " << Y << endl;
    };
    if (X == Y) break;
    X = Y;
  }
  cout << X.size() << endl;
  return 0;
}
