#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  while (true) {
    bool t = true;
    for (int i = 0; i < (int)(X.size() - 1); i++) {
      if (X[i] != 'S' || X[i + 1] != 'T') continue;
      t = false;
      int l = i, r = i + 1;
      while (0 <= l && r < X.size()) {
        if (X[l] != 'S' || X[r] != 'T') break;
        X[l] = '-', X[r] = '-';
        l--, r++;
      }
    }
    if (!t) break;
  }
  long long ans = 0;
  for (int i = 0; i < (int)(X.size()); i++) {
    if (X[i] == 'S' || X[i] == 'T') ans++;
  }
  cout << ans << endl;
}
