#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int cnt = 0;
  for (int i = 0; i < str.length() - 1; i++) {
    if (str[i] == 'S' && str[i + 1] == 'T') {
      int temp = 0;
      while (i - temp >= 0 && i + temp + 1 < str.length() &&
             str[i - temp] == 'S' && str[i + temp + 1] == 'T') {
        temp++;
      }
      cnt += temp * 2;
      i = i + temp;
    }
  }
  cout << str.length() - cnt << endl;
  return 0;
}
