#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;
const int INF = 1e8;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int index = 0;
  while (index < s.size()) {
    if (s[index] == 'S' and s[index + 1] == 'T') {
      s = s.substr(0, index) + s.substr(index + 2, s.size() - index - 2);
      if (index != 0) index--;
    } else {
      index++;
    }
  }
  cout << s.size() << endl;
}
