#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int ans = 0, i = 0, k, t;
  while (i < x.size() - 1) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      int k = i, t = i + 1;
      while (x[k] == 'S' && x[t] == 'T' && 0 <= k && t < x.size()) {
        k -= 1;
        t += 1;
        ans++;
      }
      i = t;
    } else {
      i++;
    }
  }
  cout << x.length() - 2 * ans << endl;
  return 0;
}
