#include <bits/stdc++.h>
using namespace std;
bool f[200005];
int main() {
  memset(f, 0, sizeof(f));
  string s;
  cin >> s;
  int count = 0;
  int temp = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'T') f[i] = 1, i += 2;
    if (s[i] == 'T') count++;
  }
  if (s[s.size() - 1] == 'T') count++;
  bool cc = 1;
  while (cc) {
    int i;
    for (i = 0; i < s.size(); i++) {
      if (f[i] == 1) {
        f[i] = 0;
        if (i != 0) {
          for (int j = i - 1; j >= 0; j--) {
            if (s[j] == 'S') temp++;
            if (s[j] == 'T') break;
          }
        }
      }
    }
    if (i == s.size()) cc = 0;
  }
  cout << 2 * (count - temp) << endl;
  return 0;
}
