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