#include <bits/stdc++.h>
template <class T>
inline bool cmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool cmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
using namespace std;
const int N = 1e5 + 5;
char s[N];
int res, n, sum;
int main() {
  scanf("%s", s + 1), res = n = strlen(s + 1);
  for (register int i = (1), I = (n) + 1; i < I; ++i)
    if (s[i] == 'S')
      ++sum;
    else if (sum)
      --sum, res -= 2;
  printf("%d\n", res);
  return 0;
}
