#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum = 0, size;
  string word;
  cin >> word;
  size = word.size();
  for (int i = 0; i < word.size(); i += 1) {
    if (word[i] == 'S' && word[i + 1] == 'T') {
      sum += 2;
      word.erase(i, 2);
      i -= 3;
    }
  }
  cout << size - sum;
}
