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