#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 2 * 1e18;
const int inf = 1e9 + 7;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int N = s.size();
  int ans = N;
  int Scnt = 0, Tcnt = 0;
  int i = 0;
  while (i < N) {
    if (s[i] == 'S') {
      Scnt = 0;
      while (i < N && s[i] == 'S') {
        Scnt++;
        i++;
      }
    } else if (s[i] == 'T') {
      Tcnt = 0;
      while (i < N && s[i] == 'T') {
        Tcnt++;
        i++;
      }
      ans -= 2 * min(Tcnt, Scnt);
      Tcnt = 0;
      Scnt = 0;
    }
  }
  cout << ans << endl;
}
