#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 = 0; i < sz; i++) {
    if (s[i] == 'S') {
      ch.push(s[i]);
    } else if (s[i] == 'T') {
      if (!ch.empty()) {
        if (ch.top() == 'S') {
          ch.pop();
          ans += 2;
        }
      }
    }
  }
  cout << sz - ans;
  return 0;
}
