#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int ans = 0, cnts = 0;
  for (auto&& it = begin(x); it != end(x); it++) {
    if (*it == 'S') {
      cnts++;
    } else {
      if (cnts == 0) {
        ans++;
      } else {
        cnts--;
      }
    }
  }
  ans += cnts;
  printf("%d¥n", ans);
  return 0;
}
