#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  char arr[100];
  cin >> arr;
  for (i = j = 0; arr[i] != '\0'; i++) {
    if (arr[i] != 'S' && arr[i + 1] != 'T') {
      arr[j++] = arr[i];
    }
    arr[j] = '\0';
  }
  int m = strlen(arr);
  cout << m << endl;
  return 0;
}
