#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') {
      if (s[i + 1] == 'T') {
        ans += 2;
        i += 2;
      }
    }
  }
  cout << sz - ans;
  return 0;
}
