#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int ss = 0;
  int ans = 0;
  int flg = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'S') {
      if (flg == 0)
        ss++;
      else
        ss = 1;
      flg = 0;
    } else {
      flg = 1;
      if (ss) {
        ans++;
        ss--;
      }
    }
  }
  cout << s.size() - 2 * ans << endl;
}
