#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;
signed main() {
  string S;
  cin >> S;
  long long depth = 0;
  long long ans = S.size();
  for (long long i = 0; i < (long long)(S.size()); ++i) {
    if (S[i] == 'S') {
      depth++;
    } else {
      if (depth > 0) {
        ans -= 2;
      }
      depth--;
    }
  }
  cout << ans << endl;
}
