#include <bits/stdc++.h>
using namespace std;
const int MAX_X = 200000;
using ll = long long;
int main() {
  string s;
  cin >> s;
  while (1) {
    int p = s.size();
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] == 'S') {
        if (s[i + 1] == 'T') {
          s.erase(i, 2);
          i += 2;
        }
      }
    }
    if (p == s.size() || s.size() == 2) break;
  }
  if (s == "ST")
    cout << 0 << endl;
  else
    cout << s.size() << endl;
  return 0;
}
