#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int MOD = 1e9 + 7;
const int oo = MOD;
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
int main() {
  string str;
  cin >> str;
  int ans = (int)str.size(), cnt = 0;
  bool f = 0;
  for (int i = 0; i < (int)str.size(); i++) {
    if (str[i] == 'S') {
      if (f) f = 0, cnt = 0;
      cnt++;
    } else {
      if (cnt) --cnt, ans -= 2;
      f = 1;
    }
  }
  cout << ans << '\n';
  return 0;
}
