#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> a;
  int temp = 0;
  for (int i = 0; i < (s.length()); ++i) {
    if (i == 0) {
      a.push(s[i]);
      continue;
    }
    if (s[i] == 'T' && a.top() == 'S') {
      temp++;
      a.pop();
    } else {
      a.push(s[i]);
    }
  }
  cout << s.length() - temp * 2 << endl;
}
