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