#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long c = 0;
  long long index1 = 0;
  long long index2 = 1;
  while (1) {
    if (s[index1] == 'S' && s[index2] == 'T') {
      c++;
      while (1) {
        if (index2 + 2 < s.size() && s[index2 + 1] == 'S' &&
            s[index2 + 2] == 'T') {
          c++;
          index2 = index2 + 2;
        } else if (index1 - 1 >= 0 && index2 + 1 < s.size() &&
                   s[index1 - 1] == 'S' && s[index2 + 1] == 'T') {
          c++;
          index1 = index1 - 1;
          index2 = index2 + 1;
        } else {
          index1 = index2 + 1;
          index2 = index2 + 2;
          break;
        }
      }
    } else {
      index1++;
      index2++;
    }
    if (index1 == s.size()) break;
    if (index2 == s.size()) break;
  }
  cout << s.size() - c * 2 << endl;
  return 0;
}
