#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
string x;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> x;
  while (true) {
    int len = x.length();
    if (len == 0) break;
    string second;
    for (int i = 0; i < x.length(); ++i) {
      if (i + 1 < x.length() && x[i] == 'S' && x[i + 1] == 'T') {
        i = i + 2;
      }
      if (i < x.length()) second += x[i];
    }
    if (second == "") return cout << 0 << endl, 0;
    if (x == second) break;
    x = second;
  }
  cout << x.length() << endl;
}
