#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int a = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      for (int j = i; j < s.size(); j++) {
        if (s[j] == 'T') {
          a += 2;
          break;
        }
      }
    }
  }
  cout << s.size() - a << endl;
  return 0;
}
