#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  while (1) {
    int flag = 0;
    for (int i = 0; i < S.length() - 1; i++) {
      if (S.at(i) == 'S' && S.at(i + 1) == 'T') {
        S.erase(i, 2);
        flag = 1;
      }
    }
    if (flag == 0) break;
  }
  cout << S.length() << endl;
  return 0;
}
