#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'S') i += 2;
    if (s[i] == 'S' && s[i + 1] == 'T') i += 2;
    if (s[i] == 'T') count++;
  }
  cout << 2 * count << endl;
  return 0;
}
