#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int cntt = 0;
  int cnts = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'T')
      cntt++;
    else
      break;
  }
  reverse(s.begin(), s.end());
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S')
      cnts++;
    else
      break;
  }
  cout << abs(cntt - cnts) + cntt + cnts << endl;
  return 0;
}
