#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
string a;
long long S, T;
int main() {
  cin >> a;
  while (a.find("ST") != -1) {
    a.erase(a.find("ST"), 2);
  }
  cout << a.size() << endl;
}
