#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  int ans = 0;
  for (int i = 0; i < (s.size()); i++) {
    if (s[i] == 'S') {
      cnt++;
    } else {
      if (cnt > 0) {
        cnt--;
      } else {
        ans++;
      }
    }
  }
  int t = s.size() - 1;
  while (s[t] == 'S' && t > 0) {
    t--;
    ans++;
  }
  cout << ans + cnt << endl;
}
