#include <bits/stdc++.h>
using namespace std;
const int con = 1e5 + 6;
int main() {
  string s;
  cin >> s;
  long long pos = -1;
  while ((pos = s.find("ST")), pos != string::npos) {
    s.erase(pos, 2);
  }
  cout << s.size();
}
