#include <bits/stdc++.h>
using namespace std;
int main() {
  string X;
  cin >> X;
  int n = X.size();
  vector<int> cnt(n, 0);
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (res == 0) {
      if (X[i] == 'S') {
        res++;
      }
    } else {
      if (X[i] == 'S') {
        res++;
      } else {
        res--;
      }
    }
    cnt[i] = res;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (X[i] > 0) {
      ans++;
    }
  }
  cout << n - ans << endl;
  return 0;
}
