#include <bits/stdc++.h>
using namespace std;
class Node {
 public:
  char value;
  Node *next;
  Node(int value) { this->value = value; }
};
class Stack {
 public:
  Node *top;
  Stack() { top = NULL; }
  void push(char value) {
    Node *node = new Node(value);
    node->next = top;
    top = node;
  }
  void pop() {
    if (top != NULL) top = top->next;
  }
  void Stst() {
    Node *node = top;
    int cnt = 0;
    while (node->next != NULL) {
      while (node->value != 'S') {
        node = node->next;
        cnt++;
      }
      if (node->value == 'S') {
        cnt++;
      }
      if (node->next->value == 'T' && node->value == 'S') {
        cout << cnt << "\n";
        while (cnt != 0) {
          pop();
          cnt--;
        }
      }
      node = node->next;
    }
  }
  int countt() {
    Node *node = top;
    int cnt = 0;
    while (node->next != NULL) {
      cout << node->value;
      node = node->next;
      cnt++;
    }
    return cnt;
  }
};
int main() {
  Stack *s = new Stack();
  string st;
  cin >> st;
  for (int i = st.length(); i >= 0; i--) {
    s->push(st[i]);
  }
  s->Stst();
  cout << s->countt();
  return 0;
}
