#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int cnts = 0;
  int cntt = 0;
  int n = s.size();
  bool sf = false;
  bool tf = false;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') {
      sf = true;
      if (tf) {
        ans += min(cntt, cnts);
        cnts = 0;
        tf = false;
      }
      cnts++;
      cntt = 0;
    } else {
      if (sf) {
        tf = true;
        sf = false;
      }
      cntt++;
    }
  }
  if (tf) {
    ans += min(cntt, cnts);
    cnts = 0;
    tf = false;
  }
  cout << s.size() - ans * 2 << endl;
  return 0;
}
