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