#include <bits/stdc++.h>
using namespace std;
void trim(string &s) {
  int index = 0;
  if (!s.empty()) {
    while ((index = s.find(' ', index)) != string::npos) {
      s.erase(index, 1);
    }
  }
}
int main() {
  string h;
  cin >> h;
  int panduan = 0;
  int length;
  while (panduan == 0) {
    panduan = 1;
    length = h.size() - 1;
    for (int i = 0; i < length;) {
      if (h[i] == 'S' && h[i + 1] == 'T') {
        h[i] = ' ';
        h[i + 1] = ' ';
        i += 2;
        panduan = 0;
      } else {
        ++i;
      }
    }
    trim(h);
  }
  cout << h.size() << endl;
}
