#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[250000];
  cin >> str;
  int count = 0;
  stack<char> q;
  char bt;
  int ans = 0, i = 0;
  while (str[i] != '\0') {
    count++;
    i++;
  }
  for (int j = 0; j <= count - 1; j++) {
    if (str[j] == 'S') q.push('S');
    if (str[j] == 'T') {
      bt = q.top();
      if (bt == 'T' || bt == -1)
        q.push('T');
      else if (bt == 'S') {
        q.pop();
      }
    }
  }
  cout << q.size() << endl;
  return 0;
}
