#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int L = S.size();
  int cnt = 0;
  for (int i = 0; i < L; i++) {
    if (i <= L - 2 && S[i] == 'S' && S[i + 1] == 'T') {
      int d = i, u = i + 1;
      while (0 <= d && S[d] == 'S' && S[u] == 'T' && u < L) {
        cnt++;
        d--;
        u++;
      }
    }
  }
  cout << L - cnt * 2 << endl;
  return 0;
}
