#include <bits/stdc++.h>
using namespace std;
char s[1000];
int main() {
  while (cin >> s) {
    int ans = 0;
    for (int i = 0; s[i]; i++) {
      if (s[i] == 'T')
        ans++;
      else {
        int j, k;
        int cnt1 = 0, cnt2 = 0;
        for (j = i; s[j]; j++) {
          if (s[j] != 'S') break;
          cnt1++;
        }
        k = j;
        for (k = j; s[k]; k++) {
          if (s[k] != 'T') break;
          cnt2++;
        }
        i = k - 1;
        ans += abs(cnt1 - cnt2);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
