#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'S') {
      int j = 0;
      while (S[i] == 'S') {
        i++;
        j++;
      }
      if (i >= S.size()) break;
      while (S[i] == 'T' && j > 0) {
        count += 2;
        i++;
        j--;
      }
      i--;
    }
  }
  cout << S.size() - count << endl;
}
