#include <bits/stdc++.h>
using namespace std;
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}
template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}
int main() {
  string X;
  cin >> X;
  while (1) {
    string::size_type index = X.find("ST");
    if (index == string::npos) {
      break;
    }
    X.erase(index, 2);
  }
  cout << X.length() << endl;
  return 0;
}
