#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, flag, L, R, sz;
char str[111111];
int main() {
  int i, j, group, x, y, v, Case = 0;
  while (scanf("%s", str) != EOF) {
    int len = strlen(str);
    int ans = len;
    for (i = 0; i < len - 1; ++i) {
      if (str[i] == 'S' && str[i + 1] == 'T') ans -= 2;
    }
    printf("%d\n", ans);
  }
  return 0;
}
