#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
int n, ls;
char s[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s + 1;
  n = strlen(s + 1);
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'T') {
      ls = n - i;
      break;
    }
  }
  int dif = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'S')
      dif++;
    else
      dif--;
  }
  cout << ls * 2 - dif;
}
