#include <bits/stdc++.h>
using namespace std;
stack<char> ch;
int main() {
  string s;
  int ans = 0;
  int n = 1010000;
  cin >> s;
  int sz = s.size();
  for (int i = s.size(); i >= 0; i--) {
    ch.push(s[i]);
  }
  while (!ch.empty()) {
    char t = ch.top();
    ch.pop();
    if (t == 'S') {
      char tt = ch.top();
      ch.pop();
      if (tt == 'T') {
        ans += 2;
      }
    }
  }
  cout << sz - ans;
  return 0;
}
