#include <bits/stdc++.h>
using lint = int64_t;
using namespace std;
int main() {
  string X;
  cin >> X;
  X = '_' + X;
  int sum[200010] = {};
  for (int i = 1; i < X.size(); i++) {
    sum[i] += sum[i - 1];
    if (X[i] == 'S') sum[i]++;
  }
  int ans = 0;
  for (int i = X.size() - 1; i > 0; i--) {
    if (X[i] == 'T') {
      int ssum = sum[i];
      int tsum = i - ssum;
      ans = min(ssum, tsum);
      break;
    }
  }
  cout << X.size() - 1 - ans * 2 << endl;
  return 0;
}
