#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9 + 7;
int main() {
  string x;
  cin >> x;
  int n = x.size();
  int ans = n;
  for (int i = 0; i < (n); i++) {
    int tcnt = 0, scnt = 0;
    if (x[i] == 'S') {
      while (x[i] == 'S' && i < n) {
        scnt++;
        i++;
      }
      while (x[i] == 'T' && i < n) {
        tcnt++;
        i++;
      }
      if (i != n) i--;
      ans -= 2 * min(scnt, tcnt);
    }
  }
  cout << ans << endl;
  return 0;
}
