#include <bits/stdc++.h>
using namespace std;
int main() {
  char X[200000];
  char I[200000];
  char J[200000];
  cin >> X;
  int len;
  int lend;
  len = (int)strlen(X);
  int count = len;
  int i, j;
  int cmp;
  while (1) {
    for (i = 0; i < len - 1; i++) {
      if (X[i] == 'R') {
        continue;
      } else if (X[i] == 'S' && X[i + 1] == 'T') {
        count = count - 2;
        X[i] = 'R';
        X[i + 1] = 'R';
      }
    }
    lend = count;
    strcpy(I, X);
    for (j = 0; j < lend; j++) {
      if (X[j] == 'R') {
        continue;
      } else if (X[j] == 'S' && X[j + 1] == 'T') {
        count = count - 2;
        X[i] = 'R';
        X[i + 1] = 'R';
      }
    }
    strcpy(J, X);
    cmp = strcmp(I, J);
    if (cmp == 0) {
      break;
    }
  }
  cout << count << endl;
}
