#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int S = 0, T = 0, cou = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      S++;
    } else {
      for (int j = i + 1; j - i <= S + 1; j++) {
        T++;
        if (s[j] == 'S' || T == S) {
          cou += min(S, T);
          S = 0;
          T = 0;
          i = j - 1;
          break;
        }
      }
    }
  }
  cout << s.size() - (cou * 2) << endl;
}
