#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;
constexpr int md = mod;
constexpr int inf = 1000000;
int main() {
  string str;
  cin >> str;
  int ret = 0;
  int n = (int)str.size();
  for (int i = 1; i < n; ++i) {
    if (str[i - 1] == 'S' && str[i] == 'T') {
      int index = 0;
      while (i - 1 - index >= 0 && i + index < n && str[i - 1 - index] == 'S' &&
             str[i + index] == 'T')
        ret += 2, index++;
    }
  }
  cout << n - ret << endl;
  return 0;
}
