#include <bits/stdc++.h>
using namespace std;
string x;
int main() {
  cin >> x;
  long long pos = 0;
  long long ans = 0;
  while (1) {
    if (x == "ST") {
      cout << 0 << endl;
      return 0;
    }
    while (pos + 1 < x.length() && x.substr(pos, 2) != "ST") {
      pos++;
    }
    if (pos + 1 == x.length()) {
      cout << x.length() << endl;
      return 0;
    } else {
      string newstring = x.substr(0, pos) + x.substr(pos + 2);
      x = newstring;
      pos--;
    }
  }
}
