#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long ans = s.size(), cnts = 0, cntt = 0;
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    if (flag) {
      if (s[i] == 'S')
        cnts++;
      else
        flag = false;
    }
    if (!flag) {
      if (s[i] == 'T')
        cntt++;
      else {
        ans -= 2 * min(cnts, cntt);
        cnts = 1;
        cntt = 0;
        flag = true;
      }
    }
  }
  cout << ans - 2 * min(cnts, cntt) << endl;
}
