#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string X;
  cin >> X;
  int S_count = 0, T_count = 0;
  int end_ite = X.length();
  for (int i = X.length() - 1; 0 <= i; i--)
    if (X[i] == 'T') {
      end_ite = i;
      break;
    }
  for (int i = 0; i <= end_ite; i++) {
    if (X[i] == 'S') S_count++;
    if (S_count > 0 && X[i] == 'T') T_count++;
  }
  cout << X.length() - min(S_count, T_count) * 2 << endl;
  return 0;
}
