#include <bits/stdc++.h>
using namespace std;
const int INF = (long long int)(1LL << 31) - 1;
const long long int INFl = (long long int)9223372036854775807;
const int MAX = 10000;
const long long int MOD = (long long int)1e9 + 7;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
string s;
int main() {
  cin >> s;
  int lt = 0;
  int fs = -1;
  for (int i = 0; i < s.size(); i++) {
    if (fs == -1 && s[i] == 'S') {
      fs = i;
    }
    if (s[i] == 'T') {
      lt = i;
    }
  }
  int cs = 0;
  int ct = 0;
  for (int i = fs; i <= lt; i++) {
    if (s[i] == 'S') cs++;
    if (s[i] == 'T') ct++;
  }
  cout << s.size() - ((cs) < (ct) ? (cs) : (ct)) * 2 << endl;
  return 0;
}
