#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int i;
  int cnt = 0;
  int chk = 0;
  int len = x.length();
  for (i = 0; i < x.length(); i++) {
    if (x[i] == 'S') {
      if (chk == 0) {
        cnt++;
      } else {
        chk = 0;
        cnt = 1;
      }
    } else {
      chk = 1;
      if (cnt > 0) {
        cnt--;
        len -= 2;
      }
    }
  }
  cout << len;
}
