#include <bits/stdc++.h>
using namespace std;
stack<char> q;
string s;
int main() {
  cin >> s;
  int i = 0;
  while (i < s.size()) {
    if (s[i] == 'S') {
      if (s[i + 1] == 'T') {
        i = i + 2;
      } else {
        q.push(s[i]);
        i++;
      }
    } else {
      q.push(s[i]);
      i++;
    }
  }
  cout << q.size() << endl;
  return 0;
}
