#include <bits/stdc++.h>
using namespace std;
constexpr int64_t mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  string ans = " ";
  ans += s[0];
  for (int i = 1; i < s.size(); i++) {
    if (ans[ans.size() - 1] == 'T' || ans[ans.size() - 1] == ' ') {
      ans += s[i];
      continue;
    }
    if (s[i] == 'S') {
      ans += s[i];
      continue;
    }
    ans.erase(ans.end() - 1);
  }
  cout << ans << endl;
  cout << ans.size() - 1;
}
