#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const long long LINF = 1e18;
long long int n, cnt = 0, ans = 1, a[10000000], b[10000000], c, d, cmp, cmpp, m,
                 h, w, x, y, sum = 0, pos;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool Sfl = false;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  ans = (s).size();
  for (long long int(i) = 0; (i) < (int)((s).size()); (i)++) {
    if (s[i] == 'S') {
      cnt++;
      Sfl = true;
    } else if (Sfl) {
      cnt--;
      ans -= 2;
    }
  }
  cout << (ans) << endl;
  return 0;
}
