#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main(void) {
  string X;
  cin >> X;
  long long int length = X.size();
  long long int p_s = 0, p_t = 0;
  long long int minus = 0;
  while (p_s < length && p_t < length) {
    if (X[p_s] == 'S') {
      p_t = p_s + 1;
      while (p_t < length) {
        if (X[p_t] == 'T') {
          minus += 2;
          X[p_s] = 'o';
          X[p_t] = 'o';
          break;
        }
        p_t++;
      }
    }
    p_s++;
  }
  cout << length - minus << endl;
}
