#include <bits/stdc++.h>
using namespace std;
int used[200010];
int main() {
  string s;
  cin >> s;
  int len = s.size();
  int ans = len;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'S' && i < len - 1) {
      int cntS = 0;
      int cntT = 0;
      while (s[i] == 'S') {
        i++;
        cntS++;
      }
      while (s[i] == 'T') {
        i++;
        cntT++;
      }
      ans -= (2 * (min(cntS, cntT)));
      i--;
    }
  }
  cout << ans << "\n";
  return 0;
}
