#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<int, int> mpa, mpb;
const int MAX = 100000;
int main() {
  stack<char> P;
  char r;
  string X;
  cin >> X;
  P.push(X[0]);
  for (int i = 1; i < X.size(); i++) {
    r = X[i];
    if (P.top() == 'S' && r == 'T') {
      P.pop();
    } else {
      P.push(r);
    }
  }
  cout << P.size() << endl;
  return 0;
}
