#include <bits/stdc++.h>
using namespace std;
string s;
inline long long read() {
  char c = getchar();
  int a = 1;
  long long ans = 0;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') a = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) ans = ans * 10 + int(c) - 48;
  return a * ans;
}
int main() {
  cin >> s;
  int n = s.size();
  int nn = n;
  for (int i = 0; i < nn; i++) {
    int po = i + 1;
    while (s[po] == '0') po++;
    if (s[i] == 'S' && s[po] == 'T') {
      n -= 2;
      i--;
      s[i] = s[po] = '0';
    }
  }
  cout << n << endl;
  return 0;
}
