#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
string join(const vector<T>& v, string d = " ") {
  stringstream s;
  for (ll(i) = 0; (i) < ((ll)(v).size()); ++(i)) s << d << v[i];
  return s.str().substr(d.length());
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  if ((ll)(v).size()) s << join(v, ", ");
  return s;
}
const ll inf = 1e15;
const ll mod = 1e9 + 7;
const double eps = 1e-10;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int main() {
  string X;
  cin >> X;
  X += "XX";
  for (ll i = 0; i < X.length() - 1;) {
    if (X.substr(i, 2) == "ST") {
      string Y = "";
      for (ll(j) = 0; (j) < (i); ++(j)) Y += X[j];
      for (ll(j) = i + 2; (j) < (X.length()); ++(j)) Y += X[j];
      X = Y;
      i = 0;
    } else {
      i++;
    }
  }
  cout << X.length() - 2 << endl;
  return 0;
}
