#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int i, j, count = 0, check = 1;
  while (check) {
    check = 0;
    for (i = 0; i < x.size(); i++) {
      while (x[i] == 0 && i < x.size()) i++;
      j = i + 1;
      while (x[j] == 0 && j < x.size()) j++;
      if (x[i] == 'S' && x[j] == 'T') {
        x[i] = 0;
        x[j] = 0;
        check = 1;
      }
    }
  }
  for (i = 0; i < x.size(); i++) {
    if (x[i] != 0) count++;
  }
  cout << count << endl;
  return 0;
}
