#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  int count = 0;
  for (int i = 0; s[i] != '\0'; i++) {
    int j1 = 0;
    int j2 = 0;
    if (s[i] == 'S' && s[i + 1] == 'T') {
      j1 = i;
      j2 = i + 1;
      while ((j1 >= 0 || j1 < len || j2 >= 0 || j2 < len) && s[j1] == 'S' &&
             s[j2] == 'T') {
        count++;
        j1--;
        j2++;
        if (j1 < 0 || j1 >= len || j2 < 0 || j2 >= len) {
          break;
        }
      }
    }
  }
  cout << len - count * 2;
}
