#include <bits/stdc++.h>
using namespace std;
int main(void) {
  vector<int> a;
  char c;
  while (true) {
    c = getchar();
    if (c == '\n') {
      break;
    } else if (c == 'S') {
      a.push_back(0);
    } else {
      a.push_back(1);
    }
  }
  bool flag;
  do {
    flag = false;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == 0 && a[i + 1] == 1) {
        a.erase(a.begin() + i, a.begin() + i + 2);
        flag = true;
      }
    }
  } while (flag);
  printf("%d\n", a.size());
  return 0;
}
