#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string x;
int flag;
int main() {
  cin >> x;
  int ans = 0;
  int len = x.length();
  for (;;) {
    flag = 0;
    for (int i = (0); i < (x.length() - 1); i++) {
      if (x == "ST") {
        ans++;
        flag = 0;
        break;
      } else if (x[i] == 'S' && x[i + 1] == 'T') {
        string mae = x.substr(0, i);
        string usiro;
        usiro = x.substr(i + 2, x.length() - 2 - i);
        x = mae + usiro;
        cout << x << endl;
        flag = 1;
        ans++;
      }
    }
    if (!flag) break;
  }
  cout << len - ans * 2;
  return 0;
}
