#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string p1;
  cin >> p1;
  while (p1.find("ST") != -1) {
    n = p1.find("ST");
    p1.erase(n, 2);
  }
  cout << p1.length() << endl;
}
