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