#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  for (int x = 0; x < S.length(); x++) {
    if (S[x] == 'S' && S[x + 1] == 'T') {
      long long int N = x;
      S.erase(N, 2);
      x = 0;
    }
  }
  cout << S.length() << "\n";
}
