#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
signed main() {
  string x;
  cin >> x;
  long long a = 0, b = 0, c = 0;
  for (long long i = 0; i < x.size(); i++) {
    if (x[i] == 'S')
      a++;
    else
      b++;
  }
  for (long long i = 0; i < x.size(); i++) {
    if (x[i] == 'T') {
      c++;
      b--;
    } else
      break;
  }
  for (long long i = x.size() - 1; i >= 0; i--) {
    if (x[i] == 'S') {
      c++;
      a--;
    } else
      break;
  }
  cout << c + abs(a - b) << endl;
}
