#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string X;
  cin >> X;
  int N = X.size();
  vector<pair<int, int>> dat;
  int cnt = 1;
  for (int i = 1; i < N; i++) {
    if (X[i] == X[i - 1])
      cnt++;
    else {
      dat.push_back({cnt, (X[i - 1] == 'S') ? 0 : 1});
      cnt = 1;
    }
  }
  dat.push_back({cnt, (X[N - 1] == 'S') ? 0 : 1});
  int ans = N;
  if (X[0] == 'S') {
    int mi = 1e7;
    for (int i = 0; i < dat.size(); i++) {
      if (i % 2 == 0)
        mi = dat[i].first;
      else {
        mi = min(mi, dat[i].first);
        ans -= 2 * mi;
        mi = 1e7;
      }
    }
  } else {
    int mi = 1e7;
    for (int i = 1; i < dat.size(); i++) {
      if (i % 2 == 1)
        mi = dat[i].first;
      else {
        mi = min(mi, dat[i].first);
        ans -= 2 * mi;
        mi = 1e7;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
