#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  string x;
  cin >> x;
  int s, t;
  s = t = 0;
  int garb = 0;
  int isnows = 1;
  for (int i = int(0); i < int(x.size()); ++i) {
    if (x[i] == 'S') {
      if (isnows) {
        s++;
      } else {
        if (s > t) {
          s -= t;
          t = 0;
        } else {
          garb += t - s;
          s = t = 0;
        }
        isnows = 1;
        s++;
      }
    } else {
      isnows = 0;
      t++;
    }
  }
  garb += s;
  cout << garb << endl;
}
