#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[200000];
  int ans;
  cin >> a;
  ans = strlen(a);
  for (int i = 0; i < strlen(a) - 1; i++) {
    if (a[i] == 'S' && a[i + 1] == 'T') {
      ans -= 2;
      i++;
    }
  }
  cout << ans << endl;
}
