#include <bits/stdc++.h>
using namespace std;
const long long MOD7 = 1000000007;
const long long MOD9 = 1000000009;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string X;
  cin >> X;
  if (X.length() == 2) {
    if (X == "ST") {
      cout << 0 << "\n";
    } else {
      cout << 2 << "\n";
    }
  } else {
    int idx = (int)X.find("ST");
    while (idx != -1) {
      X.replace(idx, 2, "");
      idx = (int)X.find("ST");
    }
    cout << X.length() << "\n";
  }
  return 0;
}
