#include <bits/stdc++.h>
using namespace std;
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;
}
const int inf = 1e9;
const long long linf = 3e18;
const double eps = 1e-9;
const long long MOD = 1000000007;
string s;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s;
  size_t pos;
  while ((pos = s.find("ST")) != string::npos) {
    s.erase(pos, 2);
  }
  cout << s.size() << endl;
  return 0;
}
