#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  string s;
  int ans = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = 0; i < x.length() - 1; i++) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        ans++;
        s = "";
        for (int j = 0; j < i; j++) {
          s += x[j];
        }
        for (int j = i + 1; j < x.length(); j++) {
          s += x[j];
        }
        x = s;
      }
    }
  }
  cout << x.length() << endl;
  return 0;
}
