#include <bits/stdc++.h>
const int inf = (1 << 30);
const int mod = 1000000007;
using ll = long long;
using namespace std;
int main() {
  string temp;
  cin >> temp;
  string x = "T" + temp;
  int n = x.size();
  int s = 0;
  int t = 1;
  bool flag = true;
  int ans = 0;
  for (int i = 1; i <= n + 1; ++i) {
    if (i == n + 1 or x[i - 1] == 'T' and x[i] == 'S') {
      ans += 2 * min(s, t);
      s = t = 0;
    }
    if (x[i] == 'T')
      ++t;
    else
      ++s;
  }
  cout << temp.size() - ans << endl;
}
