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