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