#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  while (1) {
    auto itr = s.find("ST");
    if (itr == string::npos) {
      break;
    } else {
      s.erase(itr, 2);
    }
  }
  cout << s.size() << endl;
  return 0;
}
