#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  string s0;
  cin >> s;
  int i;
  int lng = s.length();
  s += " ";
  s0 = "";
  int u = 0;
  while (true) {
    s0 = "";
    u = 0;
    for (i = 0; i < lng; ++i) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        ++i;
        u = 1;
      } else {
        s0 += s[i];
      }
    }
    lng = s0.length();
    s = s0 + " ";
    if (u == 0) {
      break;
    }
  }
  cout << s0.length();
}
