#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  string X;
  cin >> X;
  int N = X.size();
  int k = -1;
  for (int i = 0; i < (int)N; i++) {
    if (X[N - 1 - i] == 'T') {
      k = N - 1 - i;
      break;
    }
  }
  if (k == -1) {
    cout << N << endl;
    return 0;
  }
  int res = 0;
  for (int i = 0; i < (int)k; i++) {
    if (X[i] == 'S') res++;
  }
  cout << N - res * 2 << endl;
  return 0;
}
