#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
  cin >> S;
  for (int i = 0; i < 10000; i++) {
    for (unsigned int j = 0; j < S.size(); j += 1) {
      if (S[j] == 'S' && S[j + 1] == 'T') {
        S.erase(j);
        S.erase(j + 1);
        break;
      }
    }
  }
  cout << S.size();
}
