#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int tmp = a.find("ST");
  while (a.length() > 0 && tmp >= 0) {
    a.erase(tmp, 2);
    tmp = a.find("ST");
    if (tmp == string::npos && (a[tmp] != 'S' || a[tmp + 1] != 'T')) tmp = -1;
  }
  cout << a.length() << endl;
  return 0;
}
