#include <bits/stdc++.h>
using namespace std;
char a[20010];
int ans, sst;
int main() {
  cin >> a;
  for (int i = 0; i < strlen(a); i++) {
    if (a[i] == 'S') {
      sst++;
    } else {
      if (sst != 0) {
        sst--;
      } else {
        ans++;
      }
    }
  }
  cout << sst + ans << endl;
  return 0;
}
