#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int n = x.size();
  int ans = n;
  int s = 0, t = 0;
  for (int i = 0; i < n; i++) {
    if (x[i] == 'S') {
      s++;
      t = 0;
    } else
      t++;
    if (x[i] == 'T' && s >= t) {
      ans -= 2;
    }
  }
  cout << ans << endl;
}
