#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class 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((string(d)).length());
}
template <class T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  if ((ll)(v).size()) s << join(v, ", ");
  return s;
}
template <class T>
bool contain(const string& s, const T& v) {
  return s.find(v) != string::npos;
}
template <class T, class U>
string& replace(string& s, const T& f, const U& t) {
  for (auto p = s.find(f); p != string::npos;
       p = s.find(f, p + (string(t)).length()))
    s.replace(p, (string(f)).length(), t);
}
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;
  while (contain(X, "ST")) replace(X, "ST", "");
  cout << (string(X)).length() << endl;
  return 0;
}
