#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
ll dp[60][6000];
int main() {
  string x;
  cin >> x;
  int s = 0, t = 0, cnt = 0;
  for (int i = 0; i < x.size();) {
    while (x[i] == 'S') {
      s++;
      i++;
    }
    while (x[i] == 'T') {
      t++;
      i++;
    }
    cnt += min(t, s);
    t = s = 0;
  }
  cout << x.size() - 2 * cnt << endl;
  return 0;
}
