#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int n = str.size();
  int d = 0;
  for (int i = 0; i < str.size() - 1;) {
    if (str[i] == 'S' && str[i + 1] == 'T') {
      while ((i - d >= 0) && (i + 1 + d < str.size()) && (str[i - d] == 'S') &&
             (str[i + 1 + d] == 'T')) {
        n = n - 2;
        d++;
      }
    }
    i = i + 1 + d;
    d = 0;
  }
  cout << n << endl;
}
