#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toStr(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
int main() {
  string X;
  cin >> X;
  string ans = "";
  int s = 0, p = 0;
  for (int i = (0); i <= ((X.length()) - 1); ++i) {
    if (X[i] == 'S') {
      s++;
    } else if (X[i] == 'T') {
      if (s > 0) {
        s--;
      } else {
        ans += 'T';
      }
      p = i;
    }
  }
  ans += X.substr(p + 1, X.length() - p - 1);
  cout << ans.length() << endl;
  return 0;
}
