#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
struct At {
  char c;
  At* next;
  At* last;
} c[maxn];
int main() {
  string s;
  cin >> s;
  int size = s.size();
  c[0] = {s[0], &c[1], NULL};
  for (int i = 1; i < size - 1; i++) {
    c[i] = {s[i], &c[i + 1], &c[i - 1]};
  }
  c[size - 1] = {s[size - 1], NULL, &c[size - 2]};
  At* x = &c[0];
  while (true) {
    int update = 0;
    for (At* i = x; i->next != NULL; i = i->next) {
      if (i->c == 'S' && i->next->c == 'T') {
        if (i->last != NULL) {
          x = i->last;
          x->next = i->next->next;
          if (i->next->next != NULL) i->next->next->last = x;
        } else {
          x = i->next->next;
          if (i->next->next != NULL) i->next->next->last = NULL;
        }
        size -= 2;
        update = 1;
        break;
      }
    }
    for (At* i = x; i->next != NULL; i = i->next) cout << i->c;
    cout << endl;
    if (!update || size == 0 || x == NULL) break;
  }
  cout << size << endl;
  return 0;
}
