#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
const int INF = INT_MAX / 2;
const int MAXN = 100001;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  long long len = s.length();
  long long sNum = 0;
  for (int i = 0; i < s.length() - 1; ++i) {
    if (s[i] == 'S') {
      sNum++;
    } else {
      while (i < s.length() - 1) {
        if (sNum > 0) {
          len -= 2;
          sNum--;
        }
        if (s[i + 1] == 'T') {
          i++;
        } else {
          break;
        }
      }
    }
  }
  cout << len << endl;
}
