#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  int cnt = n / 2;
  int scnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'T') cnt--;
    if (s[i] == 'S') scnt++;
    if (cnt == 0) break;
  }
  cout << n - scnt * 2 << endl;
  return 0;
}
