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