#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double EPS = (double)1e-9;
const double pi = acos(-1.0);
const int MAXN = 1e5 + 5;
string s;
int res;
int main() {
  cin >> s;
  int cts = 0, ctt = 0;
  res = (int)s.size();
  for (int i = 0; i < (int)s.size(); i++) {
    if (s[i] == 'S') {
      if (ctt > 0) {
        res -= min(ctt, cts);
        ctt = 0;
        cts = 0;
      }
      cts++;
    } else {
      if (cts > 0) ctt++;
    }
  }
  if (cts > 0 && ctt > 0) {
    res -= min(cts, ctt);
  }
  cout << max(res, 0);
  return 0;
}
