#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int ans = N;
  stack<int> sindices, dummy;
  int d = 1;
  for (int i = 0; i < N; ++i) {
    if ('S' == X[i]) {
      sindices.push(i);
      d = 1;
    } else {
      if (!sindices.empty()) {
        int sidx = sindices.top();
        if (sidx + d == i) {
          ans -= 2;
          d += 2;
          sindices.pop();
        } else {
          sindices = dummy;
          d = 1;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
