#include <bits/stdc++.h>
using namespace std;
int const maxn = 200;
int ar[maxn];
int main() {
  string s;
  cin >> s;
  int s1 = 0, t = 0, ans = 0;
  bool a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S' && b == 1) {
      ans += min(t, s1);
      s1 = 1;
      t = 0;
      b = 0;
      a = 1;
    } else if (s[i] == 'S') {
      a = 1;
      s1++;
    } else if (s[i] == 'T') {
      if (a == 1) {
        t++;
        b = 1;
      } else {
        s1 = 0;
        t = 0;
      }
    }
  }
  if (s[s.size() - 1] == 'T') ans += min(t, s1);
  cout << s.size() - (ans * 2);
}
