#include <bits/stdc++.h>
using namespace std;
string x;
int ans;
int main() {
  cin >> x;
  ans = x.length();
  while (x.find("ST") != x.npos) {
    x.erase(x.find("ST"), 2);
    ans -= 2;
  }
  cout << ans << endl;
  return 0;
}
