#include <bits/stdc++.h>
using namespace std;
vector<char> A;
void ans() {
  vector<char>::iterator b = A.begin(), e = A.end();
  while (b != e) {
    if (*b == 'S' && *(b + 1) == 'T') {
      A.erase(b, b + 2);
      b = A.begin();
      e = A.end();
    } else {
      b++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string S;
  cin >> S;
  A.clear();
  A.resize(S.size());
  for (int i = 0; i < S.size(); i++) {
    A[i] = S[i];
  }
  ans();
  int res = A.size();
  cout << res << endl;
  return 0;
}
