#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int num1 = 0, num2 = 0, ans = 0, i, j;
  for (i = 0; i < s.length() - 1;) {
    if (s[i] == 'S') {
      for (j = i; j < s.length(); ++j) {
        if (s[j] == s[i])
          num1++;
        else {
          break;
        }
      }
      i = j;
      for (j = i; j < s.length(); ++j) {
        if (s[j] == s[i])
          num2++;
        else {
          break;
        }
      }
      i = j;
      ans += min(2 * num1, 2 * num2);
      num1 = 0, num2 = 0;
    } else
      i++;
  }
  cout << s.length() - ans << endl;
  return 0;
}
