#include <bits/stdc++.h>
using namespace std;
int ans(string yeet) {
  int i = 0;
  string torem = "ST";
rerun:
  while (i < yeet.size() - 1) {
    if (yeet.substr(i, 2) == torem) {
      if (yeet.size() > 2) {
        yeet.erase(i, 2);
        i = 0;
        goto rerun;
      }
      if (yeet.size() == 2) {
        return 0;
      }
    }
    i++;
  }
  return yeet.size();
}
int main() {
  string x;
  cin >> x;
  cout << ans(x);
}
