#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = (long long)(1e9 + 7);
const long long INF = (long long)(1e13 + 7);
long long ceil_(long long a, long long b) { return (a + (b - 1)) / b; }
long long positive_surplus(long long &a) { return (a + MOD) % MOD; }
long long bpm(long long x, unsigned long long y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  long long ans = 1;
  long long digit = (long long)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned long long i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (long long i = 0; i < container.size() - 1; i++)
    container[i + 1] += container[i];
}
signed main() {
  string X;
  cin >> X;
  long long first_S, last_T;
  for (long long i = 0; i < (long long)(X.size()); i++) {
    if (X[i] == 'S') {
      first_S = i;
      break;
    }
  }
  for (long long i = X.size() - 1; i >= 0; i--) {
    if (X[i] == 'T') {
      last_T = i;
      break;
    }
  }
  cout << X.size() - 2 * min(X.size() / 2 - first_S,
                             X.size() / 2 - (X.size() - 1 - last_T))
       << endl;
}
