#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = s.length();
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'T') ans -= 2;
  }
  cout << ans << endl;
  return 0;
}
