#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int ans = 0;
  int nums = 0, numt = 0;
  while (true) {
    for (; nums < s.size(); nums++) {
      if (s[nums] == 'S') break;
    }
    for (int i = nums; i < s.size(); i++) {
      if (s[i] == 'T') {
        numt = 1;
        break;
      }
    }
    if (numt)
      ans++;
    else
      break;
    numt = 0;
    nums++;
  }
  cout << s.size() - ans * 2 << endl;
}
