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