#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<int> t(n);
  if (s[n - 1] == 'T') t[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    t[i] = t[i + 1] + (s[i] == 'T' ? 1 : 0);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S' && t[i] > 0) cnt += 2;
  }
  cout << n - cnt << endl;
}
