#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
int main() {
  string str;
  cin >> str;
  int n = str.size();
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (str[i] == 'T' && str[i - 1] == 'S') {
      cnt++;
      int left = i - 2, right = i + 1;
      while (left >= 0 && right < n) {
        if (str[left] == 'S' && str[right] == 'T') {
          cnt++;
          left--;
          right++;
        } else
          break;
      }
    }
  }
  cout << max(n - 2 * cnt, 0) << endl;
  return 0;
}
