#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
char ch[maxn];
int len;
deque<char> Q;
int main() {
  cin >> ch;
  len = strlen(ch);
  Q.clear();
  Q.push_back(ch[0]);
  for (int i = 1; i < len; i++) {
    char u = Q.back();
    if (u == 'S' && ch[i] == 'T') {
      Q.pop_back();
      i++;
    }
    if (i < len) Q.push_back(ch[i]);
  }
  cout << Q.size() << endl;
  return 0;
}
