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