#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27);
const ll INFLL = (1LL << 55);
template <typename T, typename U>
inline void chmax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chmin(T &x, U y) {
  if (x > y) x = y;
}
char S[200010];
string f(const string &s) {
  string r = "";
  int n = s.size();
  for (int(i) = (0); i < (int)(n); i++) {
    if (i == n - 1) {
      r += s[i];
    } else if (s[i] == 'S' && s[i + 1] == 'T') {
      i++;
    } else {
      r += s[i];
    }
  }
  return r;
}
int main() {
  scanf("%s", S);
  string s = S;
  while (1) {
    string t = s;
    string a = f(s);
    if (a == t) break;
    s = a;
  }
  cout << s.size() << "\n";
  return 0;
}
