#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string s;
  cin >> s;
  long long n = s.size();
  vector<bool> alive(n, true);
  for (long long i = 0; i < (n - 1); i++) {
    for (long long l = i, r = i + 1;
         0 <= l && r < n && s[l] == 'S' && s[r] == 'T'; l--, r++) {
      alive[l] = false;
      alive[r] = false;
    }
  }
  cout << accumulate((alive).begin(), (alive).end(), 0) << endl;
}
