#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<char> q;
  q.push_back('T');
  char c;
  while (scanf("%c", &c) != EOF) {
    if (c == '\n') continue;
    if (c == 'T' && *(q.end() - 1) == 'S') {
      q.pop_back();
      continue;
    } else {
      q.push_back(c);
    }
  }
  cout << q.size() - 1;
}
