#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
string X;
void solve() {
  priority_queue<char> que;
  for (long long i = 0; i < (long long)(X.size()); i++) {
    if (X[i] == 'S') que.push(X[i]);
    if (X[i] == 'T' && (que.empty() || que.top() == 'T')) que.push('T');
    if (X[i] == 'T' && que.top() == 'S') que.pop();
  }
  cout << que.size() << endl;
}
int main() {
  cin >> X;
  solve();
  return 0;
}
