#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = int(s.size());
  int ans = n;
  int sc = 0;
  int tc = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') {
      sc++;
    } else {
      tc++;
      if (i + 1 < n) {
        if (s[i + 1] == 'S') ans -= min(sc * 2, tc * 2), sc = 0, tc = 0;
      }
    }
  }
  ans -= min(sc * 2, tc * 2);
  cout << max(ans, 0);
  return 0;
}
