#include <bits/stdc++.h>
using namespace std;
template <typename T = long long>
inline T IN() {
  T x;
  cin >> x;
  return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&...tail) {
  cin >> head;
  CIN(move(tail)...);
}
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
string X;
int tlast, tsum, ssum;
int main() {
  cin >> X;
  int N = X.length();
  for (int i = 0; i < (N); ++i) {
    if (X[i] == 'T') {
      tlast = i;
    }
  }
  tsum = count(X.cbegin(), X.cbegin() + tlast + 1, 'T');
  ssum = count(X.cbegin(), X.cbegin() + tlast + 1, 'S');
  cout << N - min(tsum, ssum) * 2 << "\n";
}
