#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MAX = 1e14 + 8;
const long long MAXN = 1e5 + 8;
const long long eps = 1e-4;
int main() {
  string s;
  cin >> s;
  bool b = 1;
  string str = s;
  while (b && !str.empty()) {
    b = 0;
    str = s;
    s = "";
    if (str == "ST") {
      cout << 0;
      return 0;
    }
    for (int i = 0; i < str.size() - 1; i++) {
      if (str[i] == 'S' && str[i + 1] == 'T') {
        s += str.substr(0, i);
        s += str.substr(i + 2, (str.size() - i - 2));
        b = 1;
        break;
      }
    }
  }
  cout << str.size();
  return 0;
}
