#include <bits/stdc++.h>
using namespace std;
template <typename T>
T& max(T& a, T& b) {
  if (a >= b) return a;
  return b;
}
template <typename T>
T& min(T& a, T& b) {
  if (a < b) return a;
  return b;
}
template <typename T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T get() {
  T a;
  cin >> a;
  return a;
}
template <typename T>
T rev(T a) {
  reverse(a.begin(), a.end());
  return a;
}
template <typename T>
vector<T>& sort(vector<T>& a) {
  sort(a.begin(), a.end());
  return a;
}
const long long inf = 1e9;
const long long linf = 3e18;
const double eps = 1e-9;
bool used[200010];
signed main() {
  string S;
  cin >> S;
  long long N = S.size();
  long long tmp = -1;
  while (N != tmp) {
    tmp = N;
    memset(used, 0, sizeof(used));
    for (long long i = 0; i < (long long)(S.size() - 1); ++i) {
      if (S[i] == 'S' && S[i + 1] == 'T') {
        used[i] = used[i + 1] = true;
      }
    }
    string s = "";
    for (long long i = 0; i < (long long)(S.size()); ++i) {
      if (!used[i]) s += S[i];
    }
    S = s;
    N = S.size();
  }
  cout << N << endl;
}
