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