#include <bits/stdc++.h>
using namespace std;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  string s;
  cin >> s;
  int ans = s.length();
  int sc = 0, tc = 0;
  for (int(i) = 0; (i) < (s.length()); (i)++) {
    if (s[i] == 'S') {
      if (i && s[i - 1] == 'T') {
        ans -= min(sc, tc) * 2;
        sc = 0, tc = 0;
      }
      sc++;
    } else if (s[i] == 'T')
      tc++;
  }
  cout << ans - min(sc, tc) * 2 << endl;
}
