#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int l = a.length();
  int s[l];
  memset(s, 0, sizeof(s));
  for (int i = 0; i <= l - 2; i++)
    for (int j = i + 1; j <= l - 1; j++)
      if (!s[i] && !s[j]) {
        if (a[i] == 'S' && a[j] == 'T') {
          s[i] = 1;
          s[j] = 1;
          i = -1;
        }
        break;
      }
  int sum = 0;
  for (int i = 0; i <= l - 1; i++)
    if (!s[i]) sum++;
  cout << sum;
  return 0;
}
