#include <bits/stdc++.h>
using namespace std;
const long long ZERO = 0;
const long long INF = 1e14;
const long long MOD = 1000000007;
const double PI = 3.1415926535897;
int main() {
  string S;
  cin >> S;
  int s = 0;
  int t = 0;
  bool cnt = true;
  int ret = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'S') {
      if (cnt == false) {
        ret += min(s, t);
        if (s > t) {
          t = 0;
          s = s - t;
        } else {
          s = 0;
          t = 0;
        }
      }
      cnt = true;
      s++;
    } else {
      cnt = false;
      t++;
    }
  }
  if (cnt == false) {
    ret += min(s, t);
    if (s > t) {
      t = 0;
      s = s - t;
    } else {
      s = 0;
      t = 0;
    }
    cnt = true;
  }
  cout << S.size() - ret * 2 << endl;
}
