#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  cin >> str;
  int pos = str.find("ST");
  int num = 0;
  int len = str.size();
  while (pos != -1) {
    str.erase(pos, 2);
    num++;
    if (num >= len / 2) break;
    pos = str.find("ST");
  }
  cout << str.size() << endl;
  return 0;
}
