#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
char c[200001] = {};
int main() {
  string s;
  cin >> s;
  c[0] = s[0];
  long long p = 1;
  for (long long i = 1; i < s.size(); i++) {
    if (p == 0) {
      c[p] = s[i];
      p++;
      continue;
    }
    if (s[p - 1] == 'S' && s[i] == 'T') {
      p--;
    } else {
      c[p] = s[i];
      p++;
    }
    c[p] = '\0';
  }
  cout << p << endl;
  return 0;
}
