#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  for (int i = 0; i < 1e5; i++) {
    int p = x.find("ST");
    if (p == -1) break;
    x.erase(x.begin() + p, x.begin() + p + 2);
  }
  cout << x.size() << endl;
}
