#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int s = 0;
  int t = 0;
  for (int i = 0; i < (int)N; i++) {
    if (X[i] == 'S') {
      s++;
    } else {
      t++;
      if (s < t) {
        t = t - s;
        s = 0;
      } else {
        s -= t;
        t = 0;
      }
    }
  }
  cout << s + t << endl;
  return 0;
}
