#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
const int MOD = 1000000007;
const int INF = 1 << 30;
int main() {
  string x;
  cin >> x;
  int n = x.size();
  bool flag = false;
  while (true) {
    flag = false;
    for (int i = 0; i < (int)(n - 1); i++) {
      if (x[i] == 'S' && x[i + 1] == 'T') {
        flag = true;
        x.erase(i, 2);
        break;
      }
    }
    if (!flag) break;
  }
  cout << x.size() << endl;
  return 0;
}
