#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string S;
  cin >> S;
  long L = S.size();
  long i = 0;
  while (1) {
    if (S[i] == 'S' && S[i + 1] == 'T')
      i += 2;
    else if (S[i] == 'T' && S[i + 1] == 'S')
      i += 2;
    else
      break;
  }
  cout << L - i;
}
