#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int flag = 0;
  while (1) {
    for (int i = 0; i < x.length(); i++) {
      if (i == x.length() - 1) {
        flag = 1;
        break;
      }
      if ((x[i] == 'S') && (x[i + 1] == 'T')) {
        x.erase(i, 2);
        break;
      }
    }
    if (x.length() < 2) break;
    if (flag) break;
  }
  cout << x.length() << endl;
  return 0;
}
