#include <bits/stdc++.h>
using namespace std;
char S[200000 + 100];
int main() {
  scanf("%s", S);
  int Cnt = 0, Ans = 0;
  int f = 0, l = 0;
  for (int i = 0; i < strlen(S); ++i)
    if (S[i] == 'S') {
      f = i;
      break;
    }
  for (int i = strlen(S) - 1; i > 0; --i)
    if (S[i] == 'T') {
      l = i;
      break;
    }
  int Cnt1 = 0, Cnt2 = 0;
  for (int i = f; i <= l; ++i)
    if (S[i] == 'S')
      Cnt1++;
    else
      Cnt2++;
  cout << strlen(S) - 2 * min(Cnt1, Cnt2) << endl;
  return 0;
}
