#include <bits/stdc++.h>
using namespace std;
long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
  string s;
  cin >> s;
  int tmp = 0;
  int cnt_s = 0;
  int cnt_t = 0;
  int ans = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (s[i] == 'S') {
      cnt_s++;
    } else {
      cnt_t++;
      if (cnt_s >= cnt_t) {
        ans++;
      }
    }
  }
  ans = s.size() - ans * 2;
  cout << ans << endl;
}
