#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  while (s.find("ST") != string::npos) {
    s = s.erase(s.find("ST"), 2);
  }
  cout << (int)s.size() << endl;
}
