#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  for (int i = 0; i < a.length() - 1; i++) {
    if (a[i] == 'S' && a[i + 1] == 'T') {
      a.erase(i, 2);
      if (i > 1)
        i -= 2;
      else {
        i--;
      }
    }
  }
  cout << a << endl;
  cout << a.length() << endl;
  return 0;
}
