#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int len = x.length();
  int acc[len + 1];
  acc[0] = 0;
  for (int i = 0; i < len; i++) {
    if (x[i] == 'S') {
      acc[i + 1] = acc[i] + 1;
    } else {
      acc[i + 1] = acc[i];
    }
  }
  int cnt = 0;
  for (int i = 1; i <= len; i++) {
    if (i > 2 * acc[i]) {
      ++cnt;
    }
  }
  cout << cnt << endl;
}
