#include <bits/stdc++.h>
using namespace std;
char c[200001];
int cc[200001];
int main() {
  cin >> c;
  int length = strlen(c);
  for (int u = 0; u < 1; u++) {
    for (int i = 0; i < length; i++) {
      if (!cc[i]) {
        for (int y = i + 1; y < length; y++) {
          if (!cc[y] && c[i] == 'S' && c[y] == 'T') {
            cc[i] = 1;
            cc[y] = 1;
            for (int n = 1; n <= i; n++) {
              if (!cc[i - n] && !cc[y + n] && c[i - n] == 'S' &&
                  c[y + n] == 'T') {
                cc[i - n] = 1;
                cc[y + n] = 1;
              } else {
                break;
              }
            }
            break;
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < length; i++) {
    if (!cc[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
