#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int kais = 0;
  while (kais < N) {
    int search = (int)S.find("ST");
    if (search != -1) {
      S.erase(S.begin() + search, S.begin() + search + 2);
      kais++;
    } else {
      break;
    }
  }
  cout << S.size() << endl;
  return 0;
}
