#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int s = 0, t = 0, sub = 0;
  for (int i = 0; i < X.size();) {
    s = 0;
    t = 0;
    while (X[i] == 'S' && i != X.size()) {
      s++;
      i++;
    }
    while (X[i] == 'T' && i != X.size()) {
      t++;
      i++;
    }
    sub += min(s, t);
    cout << sub;
  }
  cout << X.size() - sub * 2;
}
