#include <bits/stdc++.h>
using namespace std;
int main() {
  char S[222222];
  cin >> S;
  int i, N, k;
  N = 0;
  int count = 0;
  while (S[N]) N++;
  for (i = 0; i <= N - 1; i++)
    if (S[i] == 'S' && S[i + 1] == 'T') {
      k = 0;
      while (S[i - k] == 'S' && S[i + k + 1] == 'T') {
        k++;
        count++;
      };
    };
  cout << N - 2 * count << endl;
}
