#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  string x;
  int count = 0;
  cin >> x;
  int i;
  for (i = 0; i < x.length(); i++) {
    if (x[i] == 'S') {
      for (int j = i + 1; j < x.length(); j++) {
        if (x[j] == 'S') {
          break;
        } else if (x[j] == 'T') {
          count += 2;
          x[i] = '0';
          x[j] = '0';
          i = -1;
          break;
        }
      }
    }
  }
  cout << x.length() - count << endl;
  return 0;
}
