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