#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  s = '#' + s;
  int l = 0;
  while (s[l + 1] == 'T') {
    l++;
  }
  int r = 0;
  while (s[n - r] == 'S') {
    r++;
  }
  cout << (n - 2 * min(n / 2 - l, n / 2 - r));
  return 0;
}
