#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[1000000];
  cin >> str;
  int count = 0;
  int ans = 0, i = 0, j = 0;
  while (str[i] != '\0') {
    count++;
    i++;
  }
  while (str[j] != '\0') {
    if (str[j] == 'S' && str[j + 1] == 'T') {
      ans = j;
      break;
    }
    j++;
  }
  if (ans == 0)
    cout << count << endl;
  else {
    while (1) {
      for (int s = ans; s <= count - 3; s++) str[s] = str[s + 2];
      str[count - 1] = '\0';
      str[count - 2] = '\0';
      count -= 2;
      j = 0;
      while (str[j] != '\0') {
        if (str[j] == 'S' && str[j + 1] == 'T') {
          ans = j;
          break;
        }
        j++;
        if (str[j + 1] == '\0') {
          ans = -1;
          break;
        }
      }
      if (ans == -1) break;
    }
    cout << count << endl;
  }
  return 0;
}
