#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  int cnt = 0;
  int N = x.size();
  for (int i = 0; i < N - 1; i++) {
    if (x[i] == 'S' && x[i + 1] == 'T') {
      cnt++;
      int index_left = i - 1;
      int index_right = i + 2;
      for (int j = i + 2; j < N - 1; j++) {
        if (x[j] == 'S' && x[j + 1] == 'T') {
          cnt++;
          index_right = j + 2;
          j++;
        } else
          break;
      }
      int next_right = index_right;
      for (int j = 0; j < N; j++) {
        if (index_left - j >= 0 && index_right + j < N &&
            x[index_left - j] == 'S' && x[index_right + j] == 'T') {
          cnt++;
          next_right = index_right + j;
        }
      }
      i = next_right;
    }
  }
  cout << N - cnt * 2 << endl;
}
