#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string x;
  cin >> x;
  int n = x.size();
  int ans = n;
  for (int i = 0; i < x.size() - 1; i++) {
    if (x[i] == 'S') {
      if (x[i + 1] == 'T') {
        x.erase(i, 2);
        ans -= 2;
        i -= 3;
      }
    }
    if (x.size() == 0) break;
  }
  cout << x.size() << endl;
}
