#include <bits/stdc++.h>
using namespace std;
int main() {
  char* x;
  cin >> x;
  string st = "ST";
  stack<char> stack;
  for (int i = 0; i < strlen(x); i++) {
    if (x[i] == 'T') {
      if (stack.top() == 'S') {
        stack.pop();
      } else {
        stack.push(x[i]);
      }
    } else {
      stack.push(x[i]);
    }
  }
}
